open-watcom / open-watcom-v2

Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
Other
964 stars 157 forks source link

Create format PHAR EXT executable with wcl386 #1295

Closed headscott closed 3 months ago

headscott commented 4 months ago

You can do wlink with option format PHAR EXT for an executable file in this format.

But how can I tell wlink from wcl386 compiling to create this type of file?

option -bcl=PHAREXT or -bcl=PHAR EXT does not work like that...

I can do -l=PHARLAP, but this creates an .exp file with "MP" as magic number, I need "P3"

Thanks in advance

jmalak commented 4 months ago

Try -"system PHAR EXT"

headscott commented 4 months ago

If I do

wcl386 -w0 test.c -"system PHAR EXT"

it returns

Error! E3057: system block pharlap: executable format has been established
Error: Linker returned a bad status

I also tried -"format PHAR EXT" now, but then it returns

Error! E3057: file __wcl_00.lnk: line(2): executable format has been established
Error: Linker returned a bad status
jmalak commented 4 months ago

You must use -"system PHAR EXT" not -"format PHAR EXT"

headscott commented 4 months ago

But as I told you, it did not work and returned this error:

Error! E3057: system block pharlap: executable format has been established
Error: Linker returned a bad status

There was no executable file created

jmalak commented 4 months ago

It looks like wcl tool doesn't support fully. as workaround use separate wcc386 and wlink commands. It requires review wcl tool code. OW 1.9 exhibit same behaviour

headscott commented 4 months ago

So will this be fixed in future?

And for the workaround? Is there a way to look up which libraries and how the libraries would be given to the linker when I use wcl386?

jmalak commented 4 months ago

I cannot say now how and when it will be fixed without deap analysis, because it is crucial design issue and we cannot break backward compatibility. It uses shared code with owcc tool and should be fixed also for owcc tool.

Take into account that wcl386 is driver tool, only handle command line for compiler and linker tools. The libraries are handled only by linker. OW compiler write default libraries references to object files that you need not specify it anyway. If you specify library on wcl386 line then simply specify it for linker on command line by library directive, see linker documentation.

jmalak commented 4 months ago

Anyway if you want to use wcl386 for it then you can use changed linker definition file for pharlap target that it will use new definition suitable for you. The idea is based on new linker system definition and reference it from wcl386 command line. below is copy of existing PHARLAP system definition in wlink.lnk file

system begin pharlap
    libpath '%WATCOM%/lib386'
    libpath '%WATCOM%/lib386/dos'
    format phar ^
end

You can add to this file new definition for PRARLAP system as

system begin pharlapext
    libpath '%WATCOM%/lib386'
    libpath '%WATCOM%/lib386/dos'
    format phar ext
end

Then wcl386 commandline will need following options -bt=dos -l=pharlapext instead of -bcl=... option Of cause you can do hard change in existing PHARLAP system definition.

headscott commented 4 months ago

Thank you. Your last answer helped a lot. I could create an executable file in Pharlap Ext. format with P3 at the beginning. I will check if everything works fine with it as expected

jmalak commented 3 months ago

It is fixed now by adding linker pharlapext system

headscott commented 3 months ago

But I still can't do

wcl386 -w0 test.c -"system PHAR EXT"

or

wcl386 -w0 test.c -"system pharlapext"

jmalak commented 3 months ago

It is not supported to do selection of system this way. Only way is specify it by -bcl or -l option (now it works for "pharlapext") if system is not defined then default is used. use of -"....." is your business and cannot be handled by wcl386, because in quotes can be anything and it is passed directly to linker. that correct is only wcl386 -w0 test.c -bt=dos -l=pharlapext

Anyway -w0 is not good practice.

headscott commented 3 months ago

Okay thank you. I know about -w0 usually I did not use it, but I copied it anyways cause I did it in my last example

jmalak commented 3 months ago

I added pharlapext system to wlink.lnk that is part of standard OW because it is not simple way how to fix your requirements without breaking backward compatibility. This way it works for very long time from WATCOM era.