Author Topic: Compiling OpenJDK  (Read 29696 times)

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4807
  • Karma: +100/-1
    • View Profile
Re: Compiling OpenJDK
« Reply #15 on: April 10, 2023, 04:22:04 am »
Hmm, build of Odin dies with lots of errors like,
Code: [Select]
K:/work/odin/trunk/src/kernel32/console.cpp:1627:1: error: narrowing conversion
of '144' from 'int' to 'char' [-Wnarrowing]
K:/work/odin/trunk/src/kernel32/console.cpp:1627:1: error: narrowing conversion
of '128' from 'int' to 'char' [-Wnarrowing]

Thought CHAR was defined as 0..255, not 0..127. Use UCHAR? Or uCHAR?

Probably a change in GCC since 4.9.2 where warnings are now errors.

Probably, adding -Wno-narrowing to TEMPLATE_OdinCxx_CXXFLAGS seems to have fixed it.
Now I'm getting
Code: [Select]
K:/work/odin/trunk/src/kernel32/kernel32.cpp: In function 'void _GlobalMemoryStatus(MEMORYSTATUS*)':
K:/work/odin/trunk/src/kernel32/kernel32.cpp:250:33: error: 'max' was not declared in this scope
  250 |     lpMemStat->dwTotalVirtual = max(lpMemStat->dwTotalPageFile, sys[3]);
      |                                 ^~~
K:/work/odin/trunk/src/kernel32/kernel32.cpp:251:33: error: 'min' was not declared in this scope
  251 |     lpMemStat->dwAvailVirtual = min(lpMemStat->dwAvailPageFile, sys[3]);
      | 

Which I thought were declared in math.h but grepping doesn't show them.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2095
  • Karma: +160/-0
    • View Profile
Re: Compiling OpenJDK
« Reply #16 on: April 10, 2023, 04:46:06 am »
The example app at https://www.codingninjas.com/codestudio/library/min-and-max-function-in-cpp includes <iostream> and <algorithm> and works...

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4807
  • Karma: +100/-1
    • View Profile
Re: Compiling OpenJDK
« Reply #17 on: April 10, 2023, 05:10:17 am »
The example app at https://www.codingninjas.com/codestudio/library/min-and-max-function-in-cpp includes <iostream> and <algorithm> and works...

OK, stupid errors continue with mismatched types galore. I think I should try using an older GCC/G++, if it compiles, can think about adding some casts, or changing the types after.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2095
  • Karma: +160/-0
    • View Profile
Re: Compiling OpenJDK
« Reply #18 on: April 10, 2023, 05:17:41 am »
Depending how far you get, I'll have a crack at building it with gcc 12 tomorrow. I'll also post here once the GitHub import completes.

https://github.com/netlabsorg/odin32 is now complete I tried to match up the author's I knew to their GitHub profiles.
« Last Edit: April 10, 2023, 05:28:48 am by Paul Smedley »

Ibrahim Hakeem

  • Full Member
  • ***
  • Posts: 120
  • Karma: +5/-0
    • View Profile
Re: Compiling OpenJDK
« Reply #19 on: April 10, 2023, 06:08:27 am »
Apologies if this sounds silly, but has the possibility of porting a Linux release of OpenJDK been considered?

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4807
  • Karma: +100/-1
    • View Profile
Re: Compiling OpenJDK
« Reply #20 on: April 10, 2023, 06:17:15 am »
Apologies if this sounds silly, but has the possibility of porting a Linux release of OpenJDK been considered?

I'd guess Bitwise considered it. Not sure what widget set it uses but likely GTK, which would be a large job to port

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4807
  • Karma: +100/-1
    • View Profile
Re: Compiling OpenJDK
« Reply #21 on: April 10, 2023, 07:30:38 am »
Using GCC 4.5.2, it mostly just built, needed an import lib for pmkbdhk.dll and currently adding LDFLAGS=-lpmkbdhk to the kmk line. Now it's dying here.
Code: [Select]
kBuild: Linking kernel32
g++.exe: K:/work/odin/trunk/out/os2.x86/release/obj/kernel32/conbuffer.o: No such file or directory
g++.exe: K:/work/odin/trunk/out/os2.x86/release/obj/kernel32/stubs.o: No such file or directory
kBuild: Linking ntdll
kmk: *** [/@unixroot/usr/share/kbuild/footer-pass2-compiling-targets.kmk:779: K:/work/odin/trunk/out/os2.x86/release/obj/kernel32/kernel32.dll] Error 255
The failing command:
@ K:/work/odin/trunk/tools/bin/runmapsym.cmd K:/work/odin/trunk/tools/bin/wmapsym.cmd K:/work/odin/trunk/out/os2.x86/release/obj/kernel32/kernel32.map K:/work/odin/trunk/out/os2.x86/release/obj/kernel32/kernel32.sym 1>nul
kmk: *** [K:/work/odin/trunk/out/os2.x86/release/obj/kernel32/kernel32.dll] Deleting file 'K:/work/odin/trunk/out/os2.x86/release/obj/kernel32/kernel32.rsp'
kmk: *** Waiting for unfinished jobs....
weakld: error: Unresolved symbol (UNDEF) '_interlocked_cmpxchg64'.
weakld: info: The symbol is referenced by:
    K:\work\odin\trunk\out\os2.x86\release\obj\ntdll\rtl.o
Ignoring unresolved externals reported from weak prelinker.

Looks like some Makefiles need adjusting. Bedtime here, so tomorrow

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2095
  • Karma: +160/-0
    • View Profile
Re: Compiling OpenJDK
« Reply #22 on: April 10, 2023, 08:15:11 am »
Looks like you got further than me - I'm dying with a REXX error:
Code: [Select]
kBuild: Compiling unicode - U:/dev/odin32/lib/unicode/casemap.c
     1 +++   ??signal on novalue name NoValueHandler??if RxFuncQuery('SysLoadFuncs') = 1 then?do? call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs';
REX0013: Error 13 running U:\dev\odin32\tools\bin\BldLevelInf.cmd, line 1:
Invalid character in program
kmk: *** [Config.kmk:163: U:/dev/odin32/out/os2.x86/release/obj/impdef/ImpDef.bldlevel.def] Error 65523
The failing command:
@cmd /c 'set BUILD_QUIET=1 && U:/dev/odin32/tools/bin/BldLevelInf.cmd U:/dev/odin32/tools/impdef/ImpDef.def U:/dev/odin32/out/os2.x86/release/obj/impdef/ImpDef.bldlevel.def -R"U:/dev/odin32/tools/impdef/ImpDef.def" -V"#define=ODIN32_VERSION,U:/dev/odin32/include/odinbuild.h" -M"#define=ODIN32_BUILD_NR,U:/dev/odin32/include/odinbuild.h"'
kmk: *** Waiting for unfinished jobs....

Easy fix - just had to run dos2unix on the cmd file.....
« Last Edit: April 10, 2023, 08:20:02 am by Paul Smedley »

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2095
  • Karma: +160/-0
    • View Profile
Re: Compiling OpenJDK
« Reply #23 on: April 10, 2023, 11:45:40 am »
OK - so not saying this is merge worthy at all - but WIP patches that compile/link with GCC 12 are at https://github.com/netlabsorg/odin32/tree/gcc12

Zip at https://smedley.id.au/tmp/odin32-20230410.zip is not tested at all

I don't know why i had to define a bunch of things with extern "C" when I had __USE_EMX defined to I would have thought those functions should have been seen <shrug>

Same, I don't get why I had to #define __USE_EMX in some source files with I had it in the compiler line.

A (hopefully) good nights sleep might help this in the morning...

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4752
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling OpenJDK
« Reply #24 on: April 10, 2023, 05:53:55 pm »
Hi

Zip at https://smedley.id.au/tmp/odin32-20230410.zip is not tested at all

First of all, thanks for taking care on compiling Odin.

My question is, what is the suggested way for someone to test this Odin build?
I already had Odin32 on C:\usr\bin, I don't know which technique will be good to disable old odin, and point to the new compiled one.  Or maybe I just has to take a backup of the VM and replace all odin file with the new ones?

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Joop

  • Hero Member
  • *****
  • Posts: 633
  • Karma: +5/-0
    • View Profile
Re: Compiling OpenJDK
« Reply #25 on: April 10, 2023, 08:54:48 pm »
I already had Odin32 on C:\usr\bin, I don't know which technique will be good to disable old odin, and point to the new compiled one.  Or maybe I just has to take a backup of the VM and replace all odin file with the new ones?
There is not one way to start programs in OS/2. So you are going to make new directories for Odin, make your own choice in naming. Delete Odin in C:\usr\bin, place it in your new directories. Mind you also have to delete it everywhere where there is a reference to C:\usr\bin. Make  command files for starting your program. In it you refer to the new directory with that particular version of Odin before you call the program. Drawback is that two ore more versions might fight each other when active in memory and you need more memory, the latter is a worry because  OS/2 doesn't have that much and with today's applications you need more and more memory. There are also some programs which do something similar like with FF.       

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2095
  • Karma: +160/-0
    • View Profile
Re: Compiling OpenJDK
« Reply #26 on: April 10, 2023, 09:22:56 pm »
Hey Martin,

It should be sufficient to add the new Odin directory to path/libpath ahead in C:\usr\bin

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4807
  • Karma: +100/-1
    • View Profile
Re: Compiling OpenJDK
« Reply #27 on: April 10, 2023, 10:39:24 pm »
Hey Martin,

It should be sufficient to add the new Odin directory to path/libpath ahead in C:\usr\bin

And maybe start out by running odininst. And run Odininst again when reverting to the RPM versions. It sets up the registry.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2095
  • Karma: +160/-0
    • View Profile
Re: Compiling OpenJDK
« Reply #28 on: April 11, 2023, 01:27:50 am »
OK - so not saying this is merge worthy at all - but WIP patches that compile/link with GCC 12 are at https://github.com/netlabsorg/odin32/tree/gcc12

Zip at https://smedley.id.au/tmp/odin32-20230410.zip is not tested at all

I don't know why i had to define a bunch of things with extern "C" when I had __USE_EMX defined to I would have thought those functions should have been seen <shrug>

Same, I don't get why I had to #define __USE_EMX in some source files with I had it in the compiler line.

A (hopefully) good nights sleep might help this in the morning...

Updated patches committed. Now going to try and work through some warnings....

It would be good if someone else can try build this - preferably with the RPM gcc...
« Last Edit: April 11, 2023, 01:39:05 am by Paul Smedley »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4807
  • Karma: +100/-1
    • View Profile
Re: Compiling OpenJDK
« Reply #29 on: April 11, 2023, 02:48:09 am »
You need a .gitattributes file containing at the minimal,
Code: [Select]
# CRLF is crucial for OS/2 REXX files (also fine for Windows .cmd)
*.cmd eol=crlf

Compiling...
Edit: Finished compiling with GCC  9.2.0 (RPM version), seems fine.
Lots more warnings then with GCC 4.52
« Last Edit: April 11, 2023, 02:58:21 am by Dave Yeo »