adoptium / temurin-build

Eclipse Temurin™ build scripts - common across all releases/versions
Apache License 2.0
1.03k stars 249 forks source link

Improve Docs! - Invalid build.sh option: --openjdk-target #3060

Open kerner1000 opened 2 years ago

kerner1000 commented 2 years ago

I am trying to cross-build on aarm64 for Mac Intel X86_64.

I use the following command:

./makejdk-any-platform.sh --docker --clean-docker-build --openjdk-target=x86_64-unknown-linux jdk18u

(I don't know what the right target for Mac Intel is, so I wanted to try it with x86_64-unknown-linux)

I get the following error:

Invalid build.sh option: --openjdk-target=x86_64-unknown-linux

karianna commented 2 years ago

You have to use --configure-args to pass in arbitrary OpenJDK build args to that script.

kerner1000 commented 2 years ago

./makejdk-any-platform.sh --docker --clean-docker-build jdk18u --configure-args --openjdk-target=x86_64-unknown-linux

docker/dockerfile-generator.sh: line 134: ((: ---=86_64--: syntax error: operand expected (error token is "-=86_64--")
Please input a JDK between 8 & 20, or 'jdk'
karianna commented 2 years ago

Try ./makejdk-any-platform.sh --docker --clean-docker-build jdk18u --configure-args "--openjdk-target=x86_64-unknown-linux"

kerner1000 commented 2 years ago
./makejdk-any-platform.sh --docker --clean-docker-build jdk18u --configure-args "--openjdk-target=x86_64-unknown-linux"
Starting ./makejdk-any-platform.sh to configure, build (Adoptium)OpenJDK binary
Parsing opt: --docker
Possible opt arg: --clean-docker-build
Parsing opt: --clean-docker-build
Possible opt arg: jdk18u
Working dir is ./build/
[debug] COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG=false
[debug] COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG=false
JDK Image folder name: jdk-bundle/jdk-*.jdk
JRE Image folder name: jre-bundle/jre-*.jre
Skipping setting boot JDK on docker host machine
docker/dockerfile-generator.sh: line 134: ((: ---=86_64--: syntax error: operand expected (error token is "-=86_64--")
Please input a JDK between 8 & 20, or 'jdk'
karianna commented 2 years ago

./makejdk-any-platform.sh --docker --clean-docker-build --configure-args "--openjdk-target=x86_64-unknown-linux" jdk18u

kerner1000 commented 2 years ago

Thank you @karianna ! This works, the build starts, but fails later with an error:

checking whether the C compiler works... no
configure: error: in `/openjdk/build/src':
configure: error: C compiler cannot create executables
See `config.log' for more details
configure exiting with result code 77
/openjdk/build/src/make/Init.gmk:124: *** Cannot continue.  Stop.
Error: No configurations found for /openjdk/build/src.
Please run 'bash configure' to create a configuration.

OpenJDK make failed, archiving make failed logs
Archiving and compressing with gzip
Your archive was created as /openjdk/build/src/build/linux-x86_64-server-release/OpenJDK.tar.gz
Moving the artifact to location /openjdk//target//OpenJDK-makefailurelogs.tar.gz

real    0m0.002s
user    0m0.001s
sys 0m0.001s
archive done.
Failed to make the JDK, exiting
karianna commented 2 years ago

Maybe ./makejdk-any-platform.sh --docker --configure-args "--openjdk-target=x86_64-unknown-linux" jdk18u - otherwise I'm not too sure, it works for me locally.

karianna commented 2 years ago

Note to self - we should update the README.md etc on how to use --configure-args with the ""

kerner1000 commented 2 years ago

Maybe ./makejdk-any-platform.sh --docker --configure-args "--openjdk-target=x86_64-unknown-linux" jdk18u - otherwise I'm not too sure, it works for me locally.

Do you also build on aarm64?

For me it doesn't work.

karianna commented 2 years ago

No I'm on x86-64 Mac might be worth posting on our slack channel to see if someone can replicate.

kerner1000 commented 2 years ago

Where do I find the Slack channel?

smlambert commented 2 years ago

@kerner1000 - https://adoptium.net/slack to send yourself an invitation to the Adoptium Slack workspace, once in, the #build channel is a good place to ask these questions.

kerner1000 commented 2 years ago

I tried following this instructions https://github.com/adoptium/temurin-build/wiki/Building-OpenJDK-using-temurin-build-scripts-within-the-adopt-build-docker-container but this builds aarch64, I could not figure out how to build for x86_64.

smlambert commented 2 years ago

From those instructions, there are 2 different images indicated:

Pull the build docker image for your environment:
For a x64 architecture use docker image: docker pull adoptopenjdk/centos6_build_image

For a arm64 architecture use docker image: docker pull adoptopenjdk/centos7_build_image
kerner1000 commented 2 years ago

@smlambert thanks for the hint! I tried it with the centos6 image. I get the following error: ERROR: Build failed for targets 'product-images test-image static-libs-image' in configuration 'linux-x86_64-server-release' (exit code 2)

karianna commented 2 years ago

Any additional logs apart from that? Perhaps in the file system of the container?

kerner1000 commented 2 years ago

This is from the build.log:

Compiling 71 files for COMPILE_CREATE_SYMBOLS
Gendata.gmk:52: recipe for target '/Users/alex/Workspaces/OpenJDK/temurin-build/workspace/build/src/build/linux-x86_64-server-release/buildtools/create_symbols_javadoc/_the.COMPILE_CREATE_SYMBOLS_batch' failed
gmake[3]: *** [/Users/alex/Workspaces/OpenJDK/temurin-build/workspace/build/src/build/linux-x86_64-server-release/buildtools/create_symbols_javadoc/_the.COMPILE_CREATE_SYMBOLS_batch] Error 1
make/Main.gmk:147: recipe for target 'jdk.javadoc-gendata' failed
gmake[2]: *** [jdk.javadoc-gendata] Error 1
gmake[2]: *** Waiting for unfinished jobs....

ERROR: Build failed for targets 'product-images test-image static-libs-image' in configuration 'linux-x86_64-server-release' (exit code 2)
smlambert commented 2 years ago

FYI @andrew-m-leonard

andrew-m-leonard commented 2 years ago

@kerner1000 can you elaborate what the intention is here? Are you trying to build openjdk for Mac aarch64 on a Mac x64 ? is that even possible?

kerner1000 commented 2 years ago

@kerner1000 can you elaborate what the intention is here?

Are you trying to build openjdk for Mac aarch64 on a Mac x64 ? is that even possible?

Im trying to build on aarch64 for Mac Intel x86_64.

andrew-m-leonard commented 2 years ago

@gdams you've done cross compiles before, is this possible? I didn't think Xcode on Mac aarch64 could produce byte code for x64 ?

kerner1000 commented 2 years ago

I am following this instructions https://github.com/adoptium/temurin-build/wiki/Building-OpenJDK-using-temurin-build-scripts-within-the-adopt-build-docker-container To build inside Docker.

andrew-m-leonard commented 2 years ago

Those docker images are x64 Linux and aarch64 Linux respectively, not Mac

andrew-m-leonard commented 2 years ago

@kerner1000 just to be clear:

  1. You have a physical Mac aarch64 (M1) laptop ?
  2. You are trying to cross compile build OpenJDK for Mac x86_64 on this laptop ?
kerner1000 commented 2 years ago

@kerner1000 just to be clear:

  1. You have a physical Mac aarch64 (M1) laptop ?
  2. You are trying to cross compile build OpenJDK for Mac x86_64 on this laptop ?

correct!

andrew-m-leonard commented 2 years ago

@kerner1000 so from doing a bit of searching, it seems Mac x64 to aarch64 is possible as implied by this https://bugs.openjdk.org/browse/JDK-8264650 but it's not clear the other way around. Based on this you might want to try this configure arg:

--openjdk-target=x64-apple-darwin
kerner1000 commented 2 years ago

thanks @andrew-m-leonard for the hint! I tried

./makejdk-any-platform.sh --docker --configure-args "--openjdk-target=x86_64-apple-darwin" jdk18u

and get the following error:

checking for patch... /usr/bin/patch
checking for dsymutil... [not found]
configure: error: Could not find required tool for DSYMUTIL
configure exiting with result code 1
/openjdk/build/src/make/Init.gmk:124: *** Cannot continue.  Stop.
Error: No configurations found for /openjdk/build/src.
Please run 'bash configure' to create a configuration.
andrew-m-leonard commented 2 years ago

@kerner1000 dsymutil is part of Xcode, have you setup your Xcode path?

sudo xcode-select --switch  "/Applications/Xcode.app"
kerner1000 commented 2 years ago

XCode is installed. I executed your command and tried again, same error.

andrew-m-leonard commented 2 years ago

Can you check if you have all the Xcode tools installed?

which dsymutil
kerner1000 commented 2 years ago
% which dsymutil
/usr/bin/dsymutil
andrew-m-leonard commented 2 years ago

@kerner1000 What version of Xcode are you using?

andrew-m-leonard commented 2 years ago

@kerner1000 ah don't specify --docker, you aren't using that on Mac Use just:

./makejdk-any-platform.sh --configure-args "--openjdk-target=x86_64-apple-darwin" jdk18u 
kerner1000 commented 2 years ago

@andrew-m-leonard Thanks! Looks better but still:

Build performance summary:
* Build jobs:     10
* Memory limit:   32768 MB

The following warnings were produced. Repeated here for convenience:
WARNING: using cross tools not prefixed with host triplet

make: *** /Volumes: Is a directory.  Stop.
OpenJDK make failed, archiving make failed logs
Archiving and compressing with gzip
andrew-m-leonard commented 2 years ago

@kerner1000 So i've just tried the following on my Mac M1 laptop, which works, i'm using the build-farm make file which is my prefered way:

Note, I am using Xcode 13.3.1 on Mac OS 12.4 Monterey

export VARIANT=temurin
export JAVA_TO_BUILD=jdk18u
export CONFIGURE_ARGS="--openjdk-target=x86_64-apple-darwin"

build-farm/make-adopt-build-farm.sh
kerner1000 commented 2 years ago

@andrew-m-leonard thanks, I tried that. I get the following error:

Build performance summary:
* Build jobs:     10
* Memory limit:   32768 MB

The following warnings were produced. Repeated here for convenience:
WARNING: using cross tools not prefixed with host triplet

make: *** /Volumes: Is a directory.  Stop.
OpenJDK make failed, archiving make failed logs
Archiving and compressing with gzip

For me this looks like a problem with a path provided to make, maybe a whitespace, but I could not figure it out.

andrew-m-leonard commented 2 years ago

@kerner1000 is /Volumes on your PATH maybe? Can you remove /Volumes from whichever path it is in?

kerner1000 commented 2 years ago

Thanks @andrew-m-leonard, I think it is not defined:

% printenv
__CFBundleIdentifier=com.apple.Terminal
TMPDIR=/var/folders/wh/h_c77h1x42n4b64pk8g08mvw0000gn/T/
XPC_FLAGS=0x0
TERM=xterm-256color
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.mFMCxxUYxf/Listeners
XPC_SERVICE_NAME=0
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=445
TERM_SESSION_ID=6E93F076-FDE2-4EA4-9316-D6912FE78B92
SHELL=/bin/zsh
HOME=/Users/alex
LOGNAME=alex
USER=alex
PATH=/opt/homebrew/opt/node@14/bin:/Users/alex/.gem/ruby/3.0.0/bin:/Users/alex/.rbenv/shims:/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
SHLVL=1
PWD=/Users/alex/sources/temurin-build
OLDPWD=/Users/alex
HOMEBREW_NO_AUTO_UPDATE=1
HOMEBREW_PREFIX=/opt/homebrew
HOMEBREW_CELLAR=/opt/homebrew/Cellar
HOMEBREW_REPOSITORY=/opt/homebrew
MANPATH=/opt/homebrew/share/man::
INFOPATH=/opt/homebrew/share/info:
JAVA_8_HOME=/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home
JAVA_11_HOME=/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
JAVA_17_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
JAVA_18_HOME=/Library/Java/JavaVirtualMachines/temurin-18.jdk/Contents/Home
JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-18.jdk/Contents/Home
RBENV_SHELL=zsh
VARIANT=temurin
JAVA_TO_BUILD=jdk18u
CONFIGURE_ARGS=--openjdk-target=x86_64-apple-darwin
LC_CTYPE=UTF-8
_=/usr/bin/printenv
andrew-m-leonard commented 2 years ago

It's not obvious looking at that where /Volumes is coming from? Can you check the configure output for any clues?

kerner1000 commented 2 years ago

Already checked, cannot find any clue. Can you point me to the make call, maybe this can give more infos.

% pwd
/Users/alex/sources/temurin-build

% grep -r "/Volumes" .
./workspace/build/src/test/jdk/java/nio/file/etc/MacVolumesTest.java:    private static final String DATA_VOLUME = "/System/Volumes/Data";
kerner1000 commented 2 years ago

Hi @andrew-m-leonard , Thanks again for helping out! According to this 10 years old bug, make indeed has problems with whitespaces in path names: https://savannah.gnu.org/bugs/?712 I moved the sources directory to another path, now it almost succeeds:

Creating directory structure for static libs 'Contents/Home/lib/static/darwin-arm64'
~/sources/temurin-build/workspace/build/src/build/macosx-x86_64-server-release/images
moving static-libs to jdk-18.0.2+9-static-libs
Copying found debug symbols to jdk-18.0.2+9-debug-image
321532 blocks
find: jdk-18.0.2+9-jre: No such file or directory
find: jdk-18.0.2+9-jre: No such file or directory
Finished cleaning and moving archive files from jdk-18.0.2+9
From /Users/alex/sources/temurin-build/workspace/./build//src
 * branch                    HEAD       -> FETCH_HEAD
PERFORM_COPYING=false
 Skipping copying of the free font library to jdk-18.0.2+9, does not apply for this version of the JDK. 
From /Users/alex/sources/temurin-build/workspace/./build//src
 * branch                    HEAD       -> FETCH_HEAD
From /Users/alex/sources/temurin-build/workspace/./build//src
 * branch                    HEAD       -> FETCH_HEAD
cp: jdk-18.0.2+9/Contents/home//NOTICE: No such file or directory
andrew-m-leonard commented 2 years ago

@kerner1000 that should be copying sbin/NOTICE.template to the output, it's running this line: https://github.com/adoptium/temurin-build/blob/2e346aac60c09bf36d487638f00d7eb1e17c41e7/sbin/build.sh#L1176 Maybe you can check sbin/NOTICE.template exists?

andrew-m-leonard commented 2 years ago

@kerner1000 put some debug print's in your local copy of sbin/build.sh to figure why....

kerner1000 commented 2 years ago

@kerner1000 that should be copying sbin/NOTICE.template to the output, it's running this line:

https://github.com/adoptium/temurin-build/blob/2e346aac60c09bf36d487638f00d7eb1e17c41e7/sbin/build.sh#L1176

Maybe you can check sbin/NOTICE.template exists?

Thanks @andrew-m-leonard The file exists, so somehow the target dir does not exist.

ls sbin/
NOTICE.template     build.sh        build.template      common          prepareWorkspace.sh sig_check

cp: jdk-18.0.2+9/Contents/home//NOTICE: No such file or directory

Those double slashes are ok? Where should the target directory jdk-18.0.2+9 be located?

There are jdk-17 andjdk-10 folders.

temurin-build % ls
10.tgz              NOTICE              configureBuild.sh       jdk-17              security
CHANGELOG.md            README.md           cyclonedx-lib           makejdk-any-platform.1      serverTimestamp.properties
CODE_OF_CONDUCT.md      RELEASING.md            docker              makejdk-any-platform.sh     sign.sh
CONTRIBUTING.md         SmokeTesting.md         docker-build.sh         native-build.sh         signalhandler.sh
FAQ.md              Testing.md          entitlements.plist      pipelines           test
LICENSE             build-farm          jdk-10              sbin                workspace
kerner1000 commented 2 years ago

I added some debug to the build script, here is the result:

Home dir is /Volumes/Case-sensitive-Volume/sources/temurin-build/workspace/build/src/build/macosx-x86_64-server-release/images/jdk-18.0.2+9/Contents/home

Interestingly, when I print the directory content I see this:

ls /Volumes/Case-sensitive-Volume/sources/temurin-build/workspace/build/src/build/macosx-x86_64-server-release/images/jdk-18.0.2+9/Contents/
Home        Info.plist  MacOS

The error was the following:

cp: jdk-18.0.2+9/Contents/home/NOTICE: No such file or directory

You can see that the actual folder name is Home with a capital H, whereas the script prints and expects home with a lower case h.

My sources are located on a case sensitive volume (Mac's root volume is per default case insensitive)

After moving the sources back to the case insensitive default volume, it all worked!

Moving the artifact to location /Users/alex/sources/temurin-build/workspace/target//jdk18u-hotspot.tar.gz
archive done.
build.sh : 14:21:14 : All done!

So to sum up:

Thanks guys for your support, that's highly appreciated!

karianna commented 2 years ago

Will keep this open as there's some doc improvements to learn from here.

andrew-m-leonard commented 2 years ago

@kerner1000 glad you're working, I noticed the lower case "home" too, but didn't matter on my case insensitive drive. I will raise an issue to correct build.sh for that. Issue: https://github.com/adoptium/temurin-build/issues/3066

kerner1000 commented 2 years ago

Thanks @andrew-m-leonard! One more question: How can I configure or disable codesigning?

andrew-m-leonard commented 2 years ago

@kerner1000 So the default codesign identity used by the openjdk make files is "openjdk_codesign", as long as a certificate for that does not exist in your build environment then codesigning will be disabled. If openjdk_codesign certificate exists (or the one you specify by configure arg --with-macosx-codesign-identity) and the codesign tool is in the path, then the openjdk make files will invoke "codesign"...

Note, however Eclipse Temurin builds actually do this slightly differently, because we need to sign using a bespoke Eclipse Foundation signing service. We actually do a two pass make process, running the default build exploded image, then we sign, then we do a full make of the images.

kerner1000 commented 2 years ago

@andrew-m-leonard ok, then I assume my code is not code signed. But why do the binaries then contain an embedded Info.plist? How can I disable this or define another value for CFBundleIdentifier? Screenshot 2022-08-15 at 15 15 40