Author Topic: Alternatives to compiling Rust in Firefox port OS/2  (Read 45414 times)

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #15 on: May 08, 2021, 09:57:06 am »
Here's the binaries, they don't seem to need anything besides the emx dlls.
Thanks, but I'd prefer source so we can update where required....

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #16 on: May 08, 2021, 06:39:52 pm »
Yes thought I'd post them anyways in case anyone else wants to play with them.
I'd imagine it is mostly configure options to build ELF binaries from your existing source. Testing is another thing, which is where those binaries might help.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #17 on: May 08, 2021, 11:33:49 pm »
Hey Dave,,

Yes thought I'd post them anyways in case anyone else wants to play with them.
I'd imagine it is mostly configure options to build ELF binaries from your existing source. Testing is another thing, which is where those binaries might help.

Agree - except for ld-elf.exe - as we're not able to build a working a.out ld.exe from binutils source....

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #18 on: May 09, 2021, 01:15:24 am »
Well, it may be possible to do a emxelfld that calls wlink.exe and outputs a LX binary. DLLs I'm not sure about, at that building something that needs imports from DLLs might be tricky, likely no 16 bit support at all as well.
Be interesting to see the SDK for the PowerPC version of OS/2 as that was ELF based.

OS4User

  • Sr. Member
  • ****
  • Posts: 406
  • Karma: +10/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #19 on: May 09, 2021, 08:55:32 am »
Well, it may be possible to do a emxelfld that calls wlink.exe and outputs a LX binary. DLLs I'm not sure about, at that building something that needs imports from DLLs might be tricky, likely no 16 bit support at all as well.
Be interesting to see the SDK for the PowerPC version of OS/2 as that was ELF based.

True. Wlink has some limitation for 16 bit DLL. But is it really nessasery for porting software ?

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #20 on: May 10, 2021, 05:04:54 am »
Hey Dave,

Does EMXOMF only convert from AOUT to OMF but not from ELF to OMF ? I thought that if you called gcc with the -Zomf switch that then, OMF objects would he produced ?

Yes, only AOUT to OMF, with the conversion happening at compile or linking time depending on whether -Zomf is in CFLAGS as well as LDFLAGS. GCC outputs AOUT and then can call emxomf to convert the object files to OMF and we can use the native linker, native debugger etc. There's also tools like emxomfar for creating static OMF libs.
It is also possible to build executables and DLLs directly out of AOUT objects.
The problems with AOUT range from officially unsupported by GCC to just plain old too simple. Doesn't allow much in alignment options for example.

I did some more thinking about this over the weekend.... I'm not the statement GCC output AOUT is 100% correct..... Isn't it the assembler (as.exe) that produces the AOUT output? So by dropping in an as.exe built to use ELF - then GCC would produce ELF output? Linking is a whole another story, that would almost certainly require gcc changes - as ld.exe won't work, and whilst -Zomf would invoke wlink - it would also try and use emxomf to convert aout to OMF which would fail with ELF output.

I think I'll try a build of binutils with ELF output, then mess around with GCC manually to see what's possible. ie try and compile a helloworld.o with ELF output (using rebuilt as.exe); then see if an executable can be linked with wlink (manually from the command line initially).

Cheers,

Paul.

PS this is kinda getting off the topic - perhaps GCC and ELF output should be split out into a separate topic?

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #21 on: May 10, 2021, 06:33:26 am »
Yes, it would be AS actually outputting the ELF objects, I didn't realize it was hard coded what AS outputs, thought more like NASM etc where you specify the output.
GCC would still need to pass the correct source (.S) code to AS. For example, -pic doesn't make sense on AOUT but does on ELF for shared libraries as shared libraries don't have fixups like DLLs do. So just guessing, both GCC and binutils would need to target ELF.
Then it is just the question of whether wlink can convert from ELF to a LX binary. Otherwise it would mean converting from ELF to OMF then linking. I know objconv can do it, though by default it has a 15 char symbol limit and doesn't want to add an underline without forcing it to with a parameter.
For C++, there is also a question of symbol mangling, no idea if it varies.

OS4User

  • Sr. Member
  • ****
  • Posts: 406
  • Karma: +10/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #22 on: May 10, 2021, 09:43:00 am »
Then it is just the question of whether wlink can convert from ELF to a LX binary.

Once  I linked  ELF produced by NASM into LX  using  Wlink.  It was just test.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2092
  • Karma: +159/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #23 on: May 10, 2021, 11:02:04 am »
Anyone know how to use wlink to create an executable from the command line?

Using:
wlink option quiet name helloworld.exe file helloworld.obj library libc_dll.lib

gives:
Code: [Select]
Error! E2028: ___main is an undefined reference
Error! E2028: _printf is an undefined reference
Warning! W1014: stack segment not found
Warning! W1023: no starting address found, using 0001:00000000
file helloworld.obj(helloworld.obj): undefined symbol ___main
file helloworld.obj(helloworld.obj): undefined symbol _printf

Cheers,

Paul

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #24 on: May 10, 2021, 11:27:01 am »
Anyone know how to use wlink to create an executable from the command line?

Using:
wlink option quiet name helloworld.exe file helloworld.obj library libc_dll.lib

gives:
Code: [Select]
Error! E2028: ___main is an undefined reference
Error! E2028: _printf is an undefined reference
Warning! W1014: stack segment not found
Warning! W1023: no starting address found, using 0001:00000000
file helloworld.obj(helloworld.obj): undefined symbol ___main
file helloworld.obj(helloworld.obj): undefined symbol _printf

Cheers,

Paul

Looks like you are not linking to the correct library/libraries. I suspect that libc_dll.lib is for creating a DLL rather than an exectuable (which then defines "dllmain" instead of "main" etc.). I think you should try the "system" keyword on the linker commandline. It should allow to easily specify what exactly you are intending to build and will hopefully then pull in the correct libraries.
See the linker help.

OS4User

  • Sr. Member
  • ****
  • Posts: 406
  • Karma: +10/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #25 on: May 10, 2021, 11:50:42 am »
Anyone know how to use wlink to create an executable from the command line?
Using:
wlink option quiet name helloworld.exe file helloworld.obj library libc_dll.lib


Try

wlink system os2v2 option map name helloworld.exe file helloworld.obj library libc.lib

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #26 on: May 10, 2021, 04:37:52 pm »
Anyone know how to use wlink to create an executable from the command line?
Using:
wlink option quiet name helloworld.exe file helloworld.obj library libc_dll.lib


Try

wlink system os2v2 option map name helloworld.exe file helloworld.obj library libc.lib

What about crt0.obj? Or one of the other crt0*.obj files?

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #27 on: May 10, 2021, 04:48:06 pm »
I would hope that the system keyword will pull in correct startup code and libraries. It should never be necessary to explicitly link the correct startup code (that's just too involved and error prone for the average developer).

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #28 on: May 10, 2021, 05:06:00 pm »
Wouldn't the system keyword bring in Watcom startup code and libraries?
I was for a while linking xul.dll from the command line, using emxomfld, needed due to GCC producing recursive response files when 9.9.2 was first released.
Can look at a map file to see the libs linked, for helloworld.cpp I see,
Code: [Select]
W:\usr\lib\gcc\i686-pc-os2-emx\9\libgcc_so_d.lib
W:\usr\lib\libc_alias.lib
W:\usr\lib\libc_dll.lib
W:\usr\lib\libend.lib
Also
Code: [Select]
Module: W:\usr\lib\crt0.obj(D:\Temp\ccD416Lu.s)

They'll need the full pathname or the equivalent of -L, LIBPATH.
« Last Edit: May 10, 2021, 05:11:36 pm by Dave Yeo »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: Alternatives to compiling Rust in Firefox port OS/2
« Reply #29 on: May 10, 2021, 07:01:07 pm »
Perhaps something like,
Code: [Select]
emxomfld -Zno-autoconv -o hello.exe hello.o -l W:\usr\lib\gcc\i686-pc-os2-emx\9\libgcc_so_d.lib -l W:\usr\lib\libc_alias.lib -l W:\usr\lib\libc_dll.lib -l W:\usr\lib\libend.lib W:\usr\lib\crt0.obj

The -Zno-autoconv should stop emxomfld from trying to change the object to OMF and emxomfld otherwise should massage the output for wlink.