NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.42k stars 13.63k forks source link

Corretto build fails on macos #290341

Open atl-nick opened 7 months ago

atl-nick commented 7 months ago

Describe the bug

corretto{11,17,19} doesn't build correctly on macos.

Steps To Reproduce

Steps to reproduce the behavior:

nix-shell -p corretto11

Expected behavior

Expect a shell with corretto11 installed.

Screenshots

❯ nix-shell -p corretto11
warning: Nix search path entry '/Users/ncox3/.nixpkgs/darwin-configuration.nix' does not exist, ignoring
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
this derivation will be built:
  /nix/store/l7wf285zpza83672lc1dc425zs4930sq-corretto-11.0.20.9.1.drv
building '/nix/store/l7wf285zpza83672lc1dc425zs4930sq-corretto-11.0.20.9.1.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/mnny7ac1frjsz95by0xmgy3rphrda9aj-source
source root is source
unpackPhase completed in 32 seconds
Running phase: patchPhase
substituteStream(): WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. (file 'installers/mac/tar/build.gradle')
substituteStream(): WARNING: pattern workingDir\ \'/usr/bin\' doesn't match anything in file 'installers/mac/pkg/build.gradle'
substituteStream(): WARNING: pattern workingDir\ \'/usr/bin\' doesn't match anything in file 'installers/linux/alpine/tar/build.gradle'
substituteStream(): WARNING: pattern workingDir\ \'/usr/bin\' doesn't match anything in file 'installers/linux/al2/spec/build.gradle'
substituteStream(): WARNING: pattern workingDir\ \'/usr/bin\' doesn't match anything in file 'installers/windows/zip/build.gradle'
substituteStream(): WARNING: pattern command\ +=\ archSpecificFlags doesn't match anything in file 'installers/mac/tar/build.gradle'
substituteStream(): WARNING: pattern command\ +=\ archSpecificFlags doesn't match anything in file 'installers/mac/pkg/build.gradle'
substituteStream(): WARNING: pattern command\ +=\ archSpecificFlags doesn't match anything in file 'installers/linux/alpine/tar/build.gradle'
substituteStream(): WARNING: pattern command\ +=\ archSpecificFlags doesn't match anything in file 'installers/linux/al2/spec/build.gradle'
substituteStream(): WARNING: pattern command\ +=\ archSpecificFlags doesn't match anything in file 'installers/windows/zip/build.gradle'
Running phase: updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./make/autoconf/build-aux/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./make/autoconf/build-aux/config.guess
Running phase: buildPhase

FAILURE: Build failed with an exception.

* What went wrong:
Gradle could not start your build.
> Could not initialize native services.
   > Failed to load native library 'libnative-platform.dylib' for Mac OS X aarch64.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org
error: builder for '/nix/store/l7wf285zpza83672lc1dc425zs4930sq-corretto-11.0.20.9.1.drv' failed with exit code 1;
       last 10 log lines:
       > Gradle could not start your build.
       > > Could not initialize native services.
       >    > Failed to load native library 'libnative-platform.dylib' for Mac OS X aarch64.
       >
       > * Try:
       > > Run with --stacktrace option to get the stack trace.
       > > Run with --info or --debug option to get more log output.
       > > Run with --scan to get full insights.
       >
       > * Get more help at https://help.gradle.org
       For full logs, run 'nix log /nix/store/l7wf285zpza83672lc1dc425zs4930sq-corretto-11.0.20.9.1.drv'.

Additional context

I tried setting GRADLE_USER_HOME to a temp directory via export GRADLE_USER_HOME=$(mktemp -d) but then I get a different error, Cannot locate tasks that match ':installers:mac:tar:packageBuildResults' as task 'packageBuildResults' not found in project ':installers:mac:tar'. This also makes sense because the corresponding task doesn't exist in the gradle file.

Notify maintainers

@rollf

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.3.0, macOS 14.3.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/Users/ncox3/.nix-defexpr/channels/nixpkgs`
rollf commented 6 months ago

I don't have access to macos. Seems like it should actually be packaging (see here) instead of packageBuildResults.

rollf commented 6 months ago

I opened this PR for testing purposes, could you try this out @atl-nick ?

atl-nick commented 6 months ago

Thanks for looking at this, @rollf.

It still fails as mentioned in the report with, Failed to load native library 'libnative-platform.dylib' for Mac OS X aarch64, if we don't set GRADLE_USER_HOME before running gradle. Others have reported this problem, e.g. here, though I don't know why it only seems to affect the macos build in this case.

If I export GRADLE_USER_HOME=$(mktemp -d) then it gets a bit further but still ultimately fails with:

Running phase: updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./make/autoconf/build-aux/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./make/autoconf/build-aux/config.guess
Running phase: buildPhase

Welcome to Gradle 7.6.3!

Here are the highlights of this release:
 - Added support for Java 19.
 - Introduced `--rerun` flag for individual task rerun.
 - Improved dependency block for test suites to be strongly typed.
 - Added a pluggable system for Java toolchains provisioning.

For more details see https://docs.gradle.org/7.6.3/release-notes.html

> Task :prebuild:copyToolSrc
> Task :prebuild:buildTool
> Task :prebuild:generateJdkCacerts

> Task :prebuild:importAmazonCacerts
Importing keystore /private/tmp/nix-build-corretto-11.0.20.9.1.drv-1/source/amazon-cacerts to cacerts...
Entry for alias trustwaveglobalcertificationauthority successfully imported.
Entry for alias twcaglobalrootca successfully imported.
Entry for alias ucaglobalg2root successfully imported.
Entry for alias emsignrootca-g1 successfully imported.
Entry for alias gtsrootr4 successfully imported.
Entry for alias emsigneccrootca-g3 successfully imported.
Entry for alias gtsrootr3 successfully imported.
Entry for alias gtsrootr2 successfully imported.
Entry for alias globalsignrootr46 successfully imported.
Entry for alias gtsrootr1 successfully imported.
Entry for alias anfsecureserverrootca successfully imported.
Entry for alias oistewisekeyglobalrootgcca successfully imported.
Entry for alias izenpe.com successfully imported.
Entry for alias e-szignorootca2017 successfully imported.
Entry for alias tubitakkamusmsslkoksertifikasi-surum1 successfully imported.
Entry for alias acraizfnmt-rcm successfully imported.
Entry for alias oistewisekeyglobalrootgbca successfully imported.
Entry for alias atostrustedroot2011 successfully imported.
Entry for alias certumtrustedrootca successfully imported.
Entry for alias certsignrootca successfully imported.
Entry for alias naverglobalrootcertificationauthority successfully imported.
Entry for alias cfcaevroot successfully imported.
Entry for alias securesignrootca11 successfully imported.
Entry for alias accvraiz1 successfully imported.
Entry for alias microsoftrsarootcertificateauthority2017 successfully imported.
Entry for alias emsignrootca-c1 successfully imported.
Entry for alias gdcatrustauthr5root successfully imported.
Entry for alias emsigneccrootca-c3 successfully imported.
Entry for alias certsignrootcag2 successfully imported.
Entry for alias cadisigrootr2 successfully imported.
Entry for alias hongkongpostrootca3 successfully imported.
Entry for alias globaltrust2020 successfully imported.
Entry for alias microsofteccrootcertificateauthority2017 successfully imported.
Entry for alias secureglobalca successfully imported.
Entry for alias ucaextendedvalidationroot successfully imported.
Entry for alias trustwaveglobaleccp256certificationauthority successfully imported.
Entry for alias globalsignroote46 successfully imported.
Entry for alias microsece-szignorootca2009 successfully imported.
Entry for alias szafirrootca2 successfully imported.
Entry for alias autoridaddecertificacionfirmaprofesionalcifa62634068 successfully imported.
Entry for alias twcarootcertificationauthority successfully imported.
Entry for alias netlockarany(classgold)ftanstvny successfully imported.
Entry for alias trustwaveglobaleccp384certificationauthority successfully imported.
Entry for alias certumtrustednetworkca2 successfully imported.
Entry for alias certumec-384ca successfully imported.
Entry for alias comodocertificationauthority successfully imported.
Entry for alias certignarootca successfully imported.
Entry for alias ssl.comevrootcertificationauthorityecc successfully imported.
Entry for alias acraizfnmt-rcmservidoresseguros successfully imported.
Import command completed:  49 entries successfully imported, 0 entries failed or cancelled

Warning:
<certsignrootca> uses the SHA1withRSA signature algorithm which is considered a security risk. This algorithm will be disabled in a future update.
<securesignrootca11> uses the SHA1withRSA signature algorithm which is considered a security risk. This algorithm will be disabled in a future update.
<accvraiz1> uses the SHA1withRSA signature algorithm which is considered a security risk. This algorithm will be disabled in a future update.
<secureglobalca> uses the SHA1withRSA signature algorithm which is considered a security risk. This algorithm will be disabled in a future update.
<autoridaddecertificacionfirmaprofesionalcifa62634068> uses the SHA1withRSA signature algorithm which is considered a security risk. This algorithm will be disabled in a future update.
<twcarootcertificationauthority> uses the SHA1withRSA signature algorithm which is considered a security risk. This algorithm will be disabled in a future update.
<comodocertificationauthority> uses the SHA1withRSA signature algorithm which is considered a security risk. This algorithm will be disabled in a future update.

> Task :prebuild:copyCacerts
> Task :installers:mac:tar:copySource
> Task :openjdksrc:sourceDistributionTarball

> Task :installers:mac:tar:configureBuild FAILED
Runnable configure script is not present
Generating runnable configure script at /private/tmp/nix-build-corretto-11.0.20.9.1.drv-1/source/installers/mac/tar/corretto-build/buildRoot/build/.configure-support/generated-configure.sh

Autoconf is not found on the PATH, and AUTOCONF is not set.
You need autoconf to be able to generate a runnable configure script.
Error: Cannot find autoconf

I guess that error is caused by this issue. (It seems to be fixed by adding which to nativeBuildInputs.) However, that leads to:

Runnable configure script is not present
Generating runnable configure script at /private/tmp/nix-build-corretto-11.0.20.9.1.drv-1/source/installers/mac/tar/corretto-build/buildRoot/build/.configure-support/generated-configure.sh
Using autoconf at /nix/store/fxx9fci30k4jwn60nk686q9zazgrk9s0-autoconf-2.72/bin/autoconf [autoconf (GNU Autoconf) 2.72]
configure: Configuration created at Fri Feb 23 11:38:05 UTC 2024.
...
checking if custom source is suppressed (openjdk-only)... no
checking which variant of the JDK to build... normal
checking which debug level to use... release
checking which variants of the JVM to build... server
checking if absolute paths should be allowed in the build output... no, release build
checking for sdk name...
configure: error: No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK
configure exiting with result code 1

Not sure where to go from there.

rollf commented 6 months ago

Ah, sorry, I forgot to add the GRADLE_USER_HOME. As per this comment, the openjdk build on darwin is actually zulu so some/all (of my) assumptions about the build might be completely wrong. I do not have access to any darwin system so I won't be able to work in this in an efficient way. I'll still update the draft PR with the latest findings to have a common ground for further research.

rollf commented 6 months ago

@atl-nick Could you maybe share how you managed to fix the autoconf issue? I have added which to the path but it still gives this error..

atl-nick commented 6 months ago

Sorry @rollf, my bad. Double checked and I actually added both which and autoconf269.

spe888 commented 4 months ago

The problem still persists failed to load native library 'libnative-platform.dylib' for Mac OS X aarch64 (btw. corretto21 is already out)

rollf commented 4 months ago

@spe888 Progress is documented here. I will add corretto21 independently.

HealsCodes commented 4 months ago

I would very much like to install any of the corretto versions (preferably 17) but I'm running into this issue as probably any other macOS user currently is.

If there's any build testing etc. I can offer on an ARM64 Mac then I'm more than happy to!

rollf commented 4 months ago

@spe888 corretto21 has been merged.

rollf commented 4 months ago

@HealsCodes Thank you for suggestions. I'd love to work on this personally but I do not have any macOS at hand. I am happy to give you write access to my nixpkgs fork so you could work/test on this PR. Let me there if you want.

icorbett commented 2 months ago

Is there any update/hope here? I am consistently getting this error for corretto11, corretto17, and corretto21 on both amd64 macOS and arm64 macOS.

rollf commented 2 months ago

@icorbett and others: Please have a look into the linked PR for any updates. I'm happy to give access to anyone who wants to join.