OSDK 1.1 Link65.exe weird syntax error

Questions, bug reports, features requests, ... about the Oric Software Development Kit. Please indicate clearly in the title the related element (OSDK for generic questions, PictConv, FilePack, XA, Euphoric, etc...) to make it easy to locate messages.

User avatar
NekoNoNiaow
Pilot Officer
Posts: 116
Joined: Sun Jan 15, 2006 10:08 pm
Location: Montreal, Canadia

OSDK 1.1 Link65.exe weird syntax error

Post by NekoNoNiaow » Fri Jun 01, 2018 1:57 am

Hello kitties,

I am warming up with the OSDK 1.1 on Windows (freshly obtained from SVN/GitHub, using the shipped binaries) attempting to rebuild some old source of mine and I am encountering a weird error at the final linking stage.

As you can see below, link65.exe seems to choke on the generated linked.s file, pointing at main.s (also generated from main.c by the compiler) as the source of error.
I checked linked.s and main.s and could not find anything there that was suspicious at first glance nor any trace of a "06bb" anywhere.

A web search of "link65.exe 06bb:Syntax Error" yields zero usable results.
Would anyone have an idea before I start digging into link65.exe's source code? I would rather avoid that. :D

Thanks in advance!

Code: Select all

C:\Users\laurent\Desktop\Dropbox\Oric\_xs>osdk_build.bat
Building the program XS at adress $600
"Handling main"
Compiling main.C
  - preprocess
  - compile
  - convert C to assembly code
  - cleanup output
"Handling pattern"
Assembling pattern.S
"Handling draw_hstretch"
Assembling draw_hstretch.S
Linking
C:\Users\laurent\Desktop\Dropbox\Oric\_xs
Assembling
# 1 "C:\\Users\\laurent\\Desktop\\dev\\OSDK\\Osdk\\_final_\\TMP\\main.s"
C:\Users\laurent\Desktop\Dropbox\Oric\_xs\main.s(1):  06bb:Syntax error
Break after 1 errors
ERROR : Build failed.
Press any key to continue . . .

User avatar
ibisum
Squad Leader
Posts: 989
Joined: Fri Apr 03, 2009 8:56 am

Re: OSDK 1.1 Link65.exe weird syntax error

Post by ibisum » Fri Jun 01, 2018 6:59 am

I may be wildly wrong here, but isn't the reference to '06bb' an indicator that there's a bad character in the sources? Can you post the main.s in a way that its content is preserved (attach as file rather than insert text) and maybe inspect it with a hex editor to see if there are dud chars in there?

User avatar
Chema
Game master
Posts: 2262
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: OSDK 1.1 Link65.exe weird syntax error

Post by Chema » Fri Jun 01, 2018 8:12 am

I think (but I may be wrong) that the error is being issued by XA trying to assemble the file produced by the compiler from main.c and I think at line 1

We would need to have a look at your main.c file.

User avatar
Dbug
Site Admin
Posts: 2662
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: OSDK 1.1 Link65.exe weird syntax error

Post by Dbug » Fri Jun 01, 2018 10:28 pm

Chema is correct, it's in the Assembling part, not Linking.

Check the "linked.s" file in your OSDK/temp folder, it contains the concatenated list of all source codes, with some #file preprocessor directives to indicate which file the code originally came from.

User avatar
NekoNoNiaow
Pilot Officer
Posts: 116
Joined: Sun Jan 15, 2006 10:08 pm
Location: Montreal, Canadia

Re: OSDK 1.1 Link65.exe weird syntax error

Post by NekoNoNiaow » Sat Jun 02, 2018 5:07 am

Dbug wrote:
Fri Jun 01, 2018 10:28 pm
Chema is correct, it's in the Assembling part, not Linking.

Check the "linked.s" file in your OSDK/temp folder, it contains the concatenated list of all source codes, with some #file preprocessor directives to indicate which file the code originally came from.
Indeed, it looks like make.bat is still in the assembling phase despite the confusing sequence of messages.
I am puzzled that the executable "link65.exe" is actually not a linker.

Also, the fact that make.bat outputs the line "Linking" when it is actually only generating the "link.bat" coupled with the fact that "link65.exe" does actually deal with assembly language files rather than objective files was quite confusing to my inner kitten. ;)

Maybe make.bat should call that phase "chaining" or "chaining assembly files" rather than "linking"?
I already have made a few additions to make.bat so I could change that if approved. ;)

For reference, the confusing sequence of messages:

Code: Select all

Assembling draw_hstretch.S
Linking
C:\Users\laurent\Desktop\Dropbox\Oric\_xs
Assembling
# 1 "C:\\Users\\laurent\\Desktop\\dev\\OSDK\\Osdk\\_final_\\TMP\\main.s"
Regarding the encountered error, as I posted yesterday, I did check "linked.s" and found nothing wrong with it to the naked eye.
Ibisum's suggestion of a weird unicode character seems indeed sound so I will double check it with an hexadecimal editor.

Update:
I did not find anything wrong even with an hex editor for the section of "linked.s" which contains "main.s". The mystery is still complete.
But damn, this error message is totally useless. I guess I will have to look into link65.exe's source code... :(

Update2:
I must be super pooped.

After some web searching, it is clear that link65.exe is indeed the linker but the link.bat which is generated look like that:

Code: Select all

C:\Users\laurent\Desktop\dev\OSDK\Osdk\_final_\BIN\link65.exe  -d C:\Users\laurent\Desktop\dev\OSDK\Osdk\_final_\lib/ -o C:\Users\laurent\Desktop\dev\OSDK\Osdk\_final_\TMP\linked.s -f -q  C:\Users\laurent\Desktop\dev\OSDK\Osdk\_final_\TMP\main pattern.s draw_hstretch.s
Unless I am totally brain dead (that is possible) this looks very incorrect. Link65.exe should not have .s files as parameters so there must be something wrong with my OSDK make.bat file. I guess I must have broken it after my modifications...
Anyway, it is late, and I should be sleeping rather than attempt to debug this and make this even worse. :lol:

Also, is there any documentation about link65.exe? I can find some about the recent versions (ld65.exe) but not that one.

Thanks for your input!

User avatar
Dbug
Site Admin
Posts: 2662
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: OSDK 1.1 Link65.exe weird syntax error

Post by Dbug » Sat Jun 02, 2018 10:29 am

Link 65 *is* a Linker.

The fact it does not deal with OBJ and LIBs and other binaries artefacts has nothing to do.

In this particular case, Link65 glues together the parts of your program, but it also locate the external references and fetches the relevant modules from the library folder using the index file.

See:http://osdk.org/index.php?page=document ... age=linker

Think of the "Assembling" phase as the final step to generate the binary, there's no rule in the universe that says that you should do something or something else in a particular order, it may be confusing if you come with preconceived ideas on how it has worked for you on other systems, but it's like wanting to fix the Oric video display system because it does not match the concept of a normal bitmap screen with palettes :D

Just attach the linked.s file, I can try to assemble it with XA from the debugger to see what it does not like.

User avatar
NekoNoNiaow
Pilot Officer
Posts: 116
Joined: Sun Jan 15, 2006 10:08 pm
Location: Montreal, Canadia

Re: OSDK 1.1 Link65.exe weird syntax error

Post by NekoNoNiaow » Sun Jun 03, 2018 3:52 am

I see, thanks for the explanations, this finally makes sense. ;)

Even yesterday as I was struggling I had started to suspect that the cc65 linker was different from conventional linker programs which deal with object files but since I had not found proper documentation to confirm it I could not be sure I was correct (and given your link it really looks like I was waaaayyyyy too tired to search efficiently yesterday :lol:).

Thanks again!

This said, it can be useful to use standard terminology it that helps avoiding a relatively understandable confusion.
Is it a problem to modify the messages in make.bat if they can help avoid a reasonable confusion given the common meaning of these terms?

But, back to the topic of this thread ( ;) ) => still no clue what this damn error means, all ".s" files look fine
I really will have to pry open the damn sources... :?

User avatar
Dbug
Site Admin
Posts: 2662
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: OSDK 1.1 Link65.exe weird syntax error

Post by Dbug » Sun Jun 03, 2018 10:34 am

NekoNoNiaow wrote:
Sun Jun 03, 2018 3:52 am
This said, it can be useful to use standard terminology it that helps avoiding a relatively understandable confusion.
Is it a problem to modify the messages in make.bat if they can help avoid a reasonable confusion given the common meaning of these terms?
The problem is that if we "fix" the messages, we start lying and confusing even more when things fail.

In the log your originally posted, the log clearly shown that the problem was in the "Assembling" phase, and thus an issue with XA not being happy, while when it happens in the "Linking" it's clearly a problem with Link65 not being happy.

I guess the "Linker" could be renamed into a "Resolver"...

Basically I like things to represent what they are instead of what they are supposed to be based on the existing scripture that has been transmitted from the mount Sinaï from times long passed.

Let's do like Solomon and go half way: Find me a wording that removes any ambiguity in the build process without actually lying about or hiding what is actually happening behind the scenes..

We will then put this to the judgment of our army of developers.

User avatar
Chema
Game master
Posts: 2262
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: OSDK 1.1 Link65.exe weird syntax error

Post by Chema » Sun Jun 03, 2018 12:47 pm

I personally find the messages quite clear, but I don't chare if they change terminology unless I stop understanding the tool being upset.
If you can attach or copy your .c or the generated .s file (main in both cases) we could have a look. Else there is little we can do...

One thing that happens to me a lot of times whenever there is a strange error I cannot spot, is a damn #define directive. A slight error defining something which is some kind of keyword or erroneously placing a semi-colon at the end of it creates a lot of hassle in the end, as *.s files are run through the pre-processor.

User avatar
NekoNoNiaow
Pilot Officer
Posts: 116
Joined: Sun Jan 15, 2006 10:08 pm
Location: Montreal, Canadia

Re: OSDK 1.1 Link65.exe weird syntax error

Post by NekoNoNiaow » Thu Jun 07, 2018 5:27 am

Chema wrote:
Sun Jun 03, 2018 12:47 pm
If you can attach or copy your .c or the generated .s file (main in both cases) we could have a look. Else there is little we can do...

One thing that happens to me a lot of times whenever there is a strange error I cannot spot, is a damn #define directive. A slight error defining something which is some kind of keyword or erroneously placing a semi-colon at the end of it creates a lot of hassle in the end, as *.s files are run through the pre-processor.
The weird part is that this code used to compile/link/run fine with the OSDK since it is an effect that I coded for the Barbitoric back when I was still young and beautiful \(ˆˆ;)/ and I did not modify it in any way (yet).
I will keep trying but If I cannot figure it out I will post the code (it might actually already be on DBug's SVN).

I actually want to make sense of this weird error message first, and possibly fix the assembler so I get a clearer message.
If I just fix my code and leave this cryptic error message, then the next person with the same issue will have to figure out the meaning of these weird hieroglyphs as well and I would rather spare them that effort. ;)
Dbug wrote:
Sun Jun 03, 2018 10:34 am
I guess the "Linker" could be renamed into a "Resolver"...
[...]
Let's do like Solomon and go half way: Find me a wording that removes any ambiguity in the build process without actually lying about or hiding what is actually happening behind the scenes..

We will then put this to the judgment of our army of developers.
Wise words! I like the name "resolver" indeed.
I will try to come with some meaningful terms (do not hold your breath :lol:).

Update:

I think I am onto something.
Upon further examination of XA's sources I found this error message generating line:

Code: Select all

OSDK/xa.cpp(951):

sprintf(out,"%s(%u):  %04x:%s error\n",gPreprocessor.m_CurrentFile->GetCurrentFileName().c_str(),gPreprocessor.m_CurrentFile->GetCurrentLine(),TablePcSegment[gCurrentSegment],ertxt[-er-1]);
which seems to correspond to the one I am getting ("path/to/main.s(1): 06bb:Syntax error").

And looking into my sources's "Build" folder I found alongside xaerr.txt, the file symbols.txt which contains (among others) a line showing, O surprise:

Code: Select all

06bb _prep_screen
So clearly, that is what "06bb" is referring to. Now I need to figure out why the label "_prep_screen" somehow is linked to that syntax error.
The adventure continues...

User avatar
Chema
Game master
Posts: 2262
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: OSDK 1.1 Link65.exe weird syntax error

Post by Chema » Thu Jun 07, 2018 10:10 am

You could just paste the first part of your main.c file, but I still think this could be due to something that is included. If you could check your #includes for something strange...

User avatar
NekoNoNiaow
Pilot Officer
Posts: 116
Joined: Sun Jan 15, 2006 10:08 pm
Location: Montreal, Canadia

Re: OSDK 1.1 Link65.exe weird syntax error

Post by NekoNoNiaow » Fri Jun 08, 2018 12:36 am

Chema wrote:
Thu Jun 07, 2018 10:10 am
You could just paste the first part of your main.c file, but I still think this could be due to something that is included. If you could check your #includes for something strange...
Only lib.h is included and everything looks perfectly normal.
Moreover that program compiled fine last time (ok, that was 15 years ago but still :D) so I am starting to think that I am cursed. ;)

Seriously though, I think the assembler is freaking out for no reason, maybe some bug which did not exist in the previous version of the OSDK this program was initially built with.

Here is the top part of main.c, up to the function prep_screen, which is apparently the one the assembler has an issue with:

Code: Select all

//#define FINAL_VERSION
#define C_VERSION

#include	"lib.h"

extern unsigned char LabelPicture[];

typedef unsigned char	u8;
typedef unsigned char	s8;
typedef unsigned int	u16;

#ifdef C_VERSION
u8	mpaper[200];
u8	mink[200];
#else
extern u8	mpaper[200];
extern u8	mink[200];
#endif // !C_VERSION

void prep_screen( u8 col_start, u8 col_end )
{
  // ...
}
If you can figure it out, I will pray that millions of kittens pounce you on while purring loudly. ;)

User avatar
NekoNoNiaow
Pilot Officer
Posts: 116
Joined: Sun Jan 15, 2006 10:08 pm
Location: Montreal, Canadia

Re: OSDK 1.1 Link65.exe weird syntax error

Post by NekoNoNiaow » Fri Jun 08, 2018 1:28 am

Well, it looks like the error is not in my sources at all...

Here is my current OSDK_config.bat:

Code: Select all

@ECHO OFF
:: Set the build paremeters
SET OSDKADDR=$600
SET OSDKNAME=XS
SET OSDKFILE=main
And a test main.c I just created:

Code: Select all

#include "lib.h"
void main()
{
}
And here is the result of running OSKD_build.bat after removing all files except the OSDK_*.bat files and main.c in that folder:

Code: Select all

C:\Users\laurent\Desktop\Dropbox\Oric\_xs>osdk_build.bat
Building the program XS at adress $600
"Handling main"
Compiling main.C
  - preprocess

C:\Users\laurent\Desktop\Dropbox\Oric\_xs>C:\Users\laurent\Desktop\Dropbox\Oric\OSDK\Osdk\_final_\BIN\cpp.exe -lang-c++ -I C:\Users\laurent\Desktop\Dropbox\Oric\OSDK\Osdk\_final_\include -D__16BIT__ -D__NOFLOAT__ -DATMOS -DOSDKNAME_XS -nostdinc main.c C:\Users\laurent\Desktop\Dropbox\Oric\OSDK\Osdk\
_final_\TMP\main.c
  - compile

C:\Users\laurent\Desktop\Dropbox\Oric\_xs>C:\Users\laurent\Desktop\Dropbox\Oric\OSDK\Osdk\_final_\BIN\compiler.exe -Nmain -O2 C:\Users\laurent\Desktop\Dropbox\Oric\OSDK\Osdk\_final_\TMP\main.c  1>C:\Users\laurent\Desktop\Dropbox\Oric\OSDK\Osdk\_final_\TMP\main.c2
  - convert C to assembly code
  - cleanup output
Linking
C:\Users\laurent\Desktop\Dropbox\Oric\_xs
Assembling
# 1 "C:\\Users\\laurent\\Desktop\\Dropbox\\Oric\\OSDK\\Osdk\\_final_\\TMP\\main.s"
C:\Users\laurent\Desktop\Dropbox\Oric\_xs\main.s(1):  06bb:Syntax error
Break after 1 errors
ERROR : Build failed.
And here is the 06bb line in Build/symbols:

Code: Select all

0611 retstack
06bb _main
0612 enter
So it definitely always complains about the first symbol defined in the C source.

Either there is something wrong with my setup, I have noticed that the git version I am using (from Cygwin) tends to give weird permission to files on Windows so I kinda wonder if that could have side effects on some of the tools in the build chain.

Or this version of the OSDK is funky. :lol:

I will have to try with a fresh installation from the OSDK .zip file.
Are there others who use the latest OSDK? Could you guys try to reproduce this error?
I will post a .zip with the sources I am trying to compile soon.

Update:

I have been able to compile my stuff normally using the OSDK and found what the issue was!

Here is how to reproduce the issue:
  • Obtain the OSDK from the SVN folder (same as http://miniserve.defence-force.org/svn/ ... osdk/main/).
  • let's assume you put the content of that "main" folder in C:\KITTY
  • Open a CMD window, type "cd C:\KITTY"
  • type "set OSDK=C:\KITTY\Osdk\_final_" so that it points directly to the compiled version stored in _final_
  • go to the c simple example: "cd C:\KITTY\sample\c\hello_world_simple"
  • type "osdk_build.bat"
  • notice that this completely fails to compile with weird errors
The error is clearly that I set the OSDK environment variable to the Osdk/_final_ folder contained in the SVN repository.
I assumed that the version which was present in SVN in that folder would be valid but apparently it is not.

Setting OSDK to C:\KITTY solves the issue, stuff compiles fine. (My empty main.c compiles too. :lol:)

I naively assumed that since DBug used _final_ as his tests bed that the version of that folder from the SVN repository would be valid.
But it clearly seems that it is not valid.

So, I assume that having _final_ in SVN is some kind of mistake, like a .gitignore/.svnignore missing a "-Osdk/_final_/*" or something of that nature.
I guess it would be probably safer to "kitten proof" it by removing it from the SVN repo since after all:
  • it is supposed to be generated by "make"-ing the OSDK
  • it is not present in the OSDK zip file
In any case... phew... I CAN FINALLY CODE AGAIN. Yeah! :mrgreen:

User avatar
Chema
Game master
Posts: 2262
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: OSDK 1.1 Link65.exe weird syntax error

Post by Chema » Fri Jun 08, 2018 8:15 am

Yeah! Congrats! You finally found it!

It was sounding weirder and weirder with each post. I told you about to post your main so I could try to compile it, because it didn't make sense to me.

We've been not of much help, but you managed yourself exceptionally :)

User avatar
Dbug
Site Admin
Posts: 2662
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: OSDK 1.1 Link65.exe weird syntax error

Post by Dbug » Fri Jun 08, 2018 6:04 pm

NekoNoNiaow wrote:
Fri Jun 08, 2018 1:28 am
(...)
I naively assumed that since DBug used _final_ as his tests bed that the version of that folder from the SVN repository would be valid.
But it clearly seems that it is not valid.
Well

Code: Select all

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\mike>set osdk
osdk=D:\svn\public\pc\tools\osdk\main\Osdk\_final_
osdkdosbox=C:\Program Files (x86)\DOSBox-0.74\DOSBox.exe

C:\Users\mike>

Post Reply