Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openjdk17-17.0.8 does not compile when building package with Photon OS 5.0 on WSL2 #1542

Closed
dcasota opened this issue Mar 4, 2024 · 3 comments
Labels

Comments

@dcasota
Copy link
Contributor

dcasota commented Mar 4, 2024

Describe the bug

no priority, just fyi

Make build of a new iso fails when building package openjdk17. As the summary suggests, when building in WSL2, the package
make build fails. This doesn't happen e.g. on VMware Workstation.

The configuration script ./stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh tries to analyze the environment. x86_64-pc-wsl as build system type is detected correctly, however openjdk-build os-cpu = windows-x86_64, windows environment type = wsl1 and wslpath not found are wrong. The expected detection should include linux-x86_64 with wsl2 and /bin/wslpath or /usr/bin/wslpath (both are symbolic links of /init.

Reproduction steps

  1. @lamw-style of an unsupported but documented setup of Photon OS 5.0 on WSL2, documented here.
    Photon OS on WSL2 is installed as user distribution and not as replacement of the system distribution cbl-mariner.
  2. build iso from source

Expected behavior

successful make build on Photon OS on WSL2

Additional context

Similar to https://bugs.busybox.net/show_bug.cgi?id=14561.
I will update this issue in case of problem solving news.

@dcasota dcasota added the bug label Mar 4, 2024
@sshedi
Copy link
Contributor

sshedi commented Mar 4, 2024

building Photon OS on WSL is not in our scope. Please don't create issues on something which are not in our scope.

@dcasota
Copy link
Contributor Author

dcasota commented Mar 4, 2024

strange, starting ./stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/configure manually, shows that wslpath is found in the 2nd turn, also, wsl2 is detected.

[...]
configure: WARNING: Ignoring value of PATHTOOL from the environment. Use command line variables instead.
checking for cygpath... [not found]
checking for wslpath... /usr/bin/wslpath
checking for cmd.exe... /mnt/c/Windows/system32/cmd.exe
checking build system type... x86_64-pc-wsl
checking host system type... x86_64-pc-wsl
checking target system type... x86_64-pc-wsl
checking openjdk-build os-cpu... windows-x86_64
checking openjdk-target os-cpu... windows-x86_64
checking compilation type... native
checking Windows environment type... wsl2
checking wsl2 drive prefix... '/mnt'
checking wsl2 root directory as Windows path... '\\wsl.localhost\Ph5'
checking wsl2 temp directory... /usr/bin/wslpath: Invalid argument
Usage:    -a    force result to absolute path format    -u    translate from a Windows path to a WSL path (default)    -w    translate from a WSL path to a Windows path    -m    translate from a WSL path to a Windows path, with '/' instead of '\'EX: wslpath 'c:\users'
/root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh: line 12873: cd: Usage:    -a    force result to absolute path format    -u    translate from a Windows path to a WSL path (default)    -w    translate from a WSL path to a Windows path    -m    translate from a WSL path to a Windows path, with '/' instead of '\'EX: wslpath 'c:\users': No such file or directory
cp: cannot create regular file 'Usage:    -a    force result to absolute path format    -u    translate from a Windows path to a WSL path (default)    -w    translate from a WSL path to a Windows path    -m    translate from a WSL path to a Windows path, with '\''/'\'' instead of '\''\'\''EX: wslpath '\''c:\users'\''': No such file or directory
checking wsl2 release... 5.15.146.1-microsoft-standard-WSL2+
checking wsl2 version... #1 SMP Sat Mar 2 11:58:41 CET 2024
checking Windows version... /root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh: line 12899: cd: too many arguments

checking wsl distribution... /root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh: line 12924: -d: command not found

checking what kind of 'find' is first on the PATH... unix style
/root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/make/scripts/fixpath.sh: illegal option -- a
/root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/make/scripts/fixpath.sh: illegal option -- a
configure: error: The path of TOPDIR, which resolves as "/root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5", could not be imported.

Copying the source to /usr/src/photon/SOURCES helps, but rpmbuild still fails.

Here the findings so far.

topdir issue

The topdir issue has been mentioned in #1412 (comment). Sort of same issue as the progress outcome seems similar.

root [ ~/photon/stage/photonroot/openjdk17-17.0.8 ]# ls
bin  boot  dev  etc  home  inputrpms  lib  lib64  media  mnt  proc  publishrpms  publishxrpms  root  run  sbin  srv  sys  tmp  usr  var
root [ ~/photon/stage/photonroot/openjdk17-17.0.8 ]# mkdir ./rpmbuild
root [ ~/photon/stage/photonroot/openjdk17-17.0.8 ]# cd rpmbuild/
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# mkdir -p $PWD/{RPMS,SRPMS,SOURCES,SPECS,LOGS,BUILD,BUILDROOT}
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# ls
BUILD  BUILDROOT  LOGS  RPMS  SOURCES  SPECS  SRPMS
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# cd SOURCES
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild/SOURCES ]# rpm2cpio https://packages.vmware.com/photon/5.0/photon_srpms_5.0_x86_64/openjdk17-17.0.8-6.ph5.src.rpm | cpio -idm
206780 blocks
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild/SOURCES ]# cd ..
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# cp SOURCES/openjdk17.spec SPECS/openjdk17.spec
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# rpmbuild -bb SPECS/openjdk17.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.0Yrhu2
+ umask 022
+ cd /usr/src/photon/BUILD
+ cd /usr/src/photon/BUILD
+ rm -rf jdk17u-jdk-17.0.8-5
+ /usr/lib/rpm/rpmuncompress -x /usr/src/photon/SOURCES/jdk-17.0.8-5.tar.gz
error: File /usr/src/photon/SOURCES/jdk-17.0.8-5.tar.gz: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.0Yrhu2 (%prep)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.0Yrhu2 (%prep)

After rpmbuild, there are two directories build and BUILD in /usr/src/photon/ as consequence of the topdir issue.

build  BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS

No solution found yet. On the rpmbuild output, the first indicator of an uppercase/lowercase issue is the build directory in checking for top-level directory... /usr/src/photon/build/jdk17u-jdk-17.0.8-5.

lsb_release

lsb_release isn't installed on Photon OS. Therefore /usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh fails on line 12924 with -d: command not found.
There is a workaround: Shutdown the user distribution of Photon OS. Login on the system distribution. Run tdnf install lsb-release. Logout. Start Photon OS and login. Set variable export LSB_RELEASE="/usr/bin/lsb_release".

gnu make

gnu make seems to be necessary.
I installed gnu make 3.82 manually and started ./configure MAKE=/usr/bin/gmake, but rpmbuild still fails. gmake 3.82 was been installed using info-5.1-5.el7.x86_64.rpm and make-3.82-24.el7.x86_64.rpm. Configured ln -s /usr/bin/gmake /opt/gmake3.81/gmake.

fixpath

The rpmbuild output issue fixpath is strange. The file simply contains the export PATH and runs wslpath.

#!/bin/bash
export PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files (x86)/VMware/VMware Workstation/bin/:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/libnvvp:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Program Files/usbipd-win/"
. /usr/src/photon/build/jdk17u-jdk-17.0.8-5/make/scripts/fixpath.sh -e /usr/bin/wslpath -p /mnt -r \\\\wsl.localhost\\Ph5 -t /mnt/c/Users/dcaso/AppData/Local/Temp -c /mnt/c/Windows/system32/cmd.exe -q "$@"

Because of the uppercase/lowercase issue, the following workaround helped:

ln -s /usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/make /usr/src/photon/build/jdk17u-jdk-17.0.8-5

Before rerunning rpmbuild with buildroot, I also did a few reinstalls: tdnf reinstall tdnf, tdnf install openjdk17.
rpmbuild now works so far, but fails at the end because of a Boot JDK issue.
After having added export PATH="/usr/lib/jvm/OpenJDK-17/bin/:$PATH", BOOT JDK is solved. rpmbuild proceeded until toolchain microsoft.

ms build tools for visual studio

Depending on the Visual Studio edition, the build tools for Visual Studio must be explicitly downloaded from https://visualstudio.microsoft.com/de/downloads/ and installed. vcvars.bat is installed by default in C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\vsdevcmd\ext. I tried the following on windows:

mkdir "C:\Program Files\Microsoft Visual Studio\2022\Community\vc\bin\amd64"
copy "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\vsdevcmd\ext\vcvars.bat" "C:\Program Files\Microsoft Visual Studio\2022\Community\vc\bin\amd64\vcvars64.bat"
mkdir "C:\Program Files\Microsoft Visual Studio\2022\Community\vc\bin\amd64\vcvars"
copy "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\vsdevcmd\ext\vcvars\*" "C:\Program Files\Microsoft Visual Studio\2022\Community\vc\bin\amd64\vcvars\"

The recognition seems to work, but rpmbuild didn't extract the environment variables needed for the VS setup.

A successful make build of an iso on Photon OS on WSL2 could include microsoft certs as custom certs for secure boot.

March 7th 2024: I haven't found out how to make build successfully openjdk17.0.8 on wsl2. Accordingly to https://mail.openjdk.org/pipermail/jdk-updates-dev/2024-January/029089.html, the issue of os detection might be a known bug JDK-8312620: WSL Linux build crashes after JDK-8310233, which should have been fixed with openjdk17.0.10. However, accordingly to https://wiki.openjdk.org/display/Build/Supported+Build+Platforms, WSL2 is not officially supported.

@dcasota
Copy link
Contributor Author

dcasota commented Dec 22, 2024

Same compile issue in (unsupported) WSL2 with latest openjdk17-17.0.13-2.ph5 package. Running ./stage/photonroot/openjdk17-17.013-2.ph5/usr/src/photon/BUILD/jdk17u-jdk-17.0.13-ga/configure manually, results in a 'too long' path issue.

[...]
checking wsl2 release... 6.6.36.6-microsoft-standard-WSL2+
checking wsl2 version... #1 SMP Sun Dec 15 15:24:02 CET 2024
checking Windows version... 10.0.26100.2605
checking wsl distribution... /home/user/photon/stage/photonroot/openjdk17-17.0.13-2.ph5/usr/src/photon/BUILD/jdk17u-jdk-17.0.13-ga/build/.configure-support/generated-configure.sh: line 12940: -d: command not found

configure: error: Your base path is too long. It is 103 characters long, but only 100 is supported
configure exiting with result code 1

Reducing the path length leads to the same wsl2 windows boot detection specific issues as before.

Root cause

Accordingly to https://openjdk.org/groups/build/doc/building.html, section 'Windows Subsystem for Linux (WSL)': "To build Linux binaries, you must use a Linux boot JDK. The default behavior is to build for Windows. To build for Linux, pass --build=x86_64-unknown-linux-gnu --openjdk-target=x86_64-unknown-linux-gnu to configure." The system recognition works flawlessly on vSphere, Workstation, etc. On wsl, the default behavior to build for Windows leads to the issues above.

Workaround

Modify the openjdk17 spec file and add the build parameter.

PHOTONROOT=~/photon # depending of your builder system
cp $PHOTONROOT/SPECS/openjdk/openjdk17.spec $PHOTONROOT/openjdk17.spec.tmp
sed "s/--disable-warnings-as-errors/--disable-warnings-as-errors --build=x86_64-unknown-linux-gnu/" $PHOTONROOT/openjdk17.spec.tmp > $PHOTONROOT/SPECS/openjdk/openjdk17.spec
rm $PHOTONROOT/openjdk17.spec.tmp

Afterwards the make build process finishes successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants