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

corretto: fix Darwin build #290808

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

corretto: fix Darwin build #290808

wants to merge 10 commits into from

Conversation

rollf
Copy link
Contributor

@rollf rollf commented Feb 23, 2024

Description of changes

This PR is motiaved by #290341 .

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@wegank
Copy link
Member

wegank commented Feb 23, 2024

@ofborg build corretto11

@@ -58,6 +58,8 @@ jdk.overrideAttrs (finalAttrs: oldAttrs: {
# Corretto's actual built is triggered via `gradle`.
gradle --console=plain --no-daemon ${task}

set -xv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed to fix the Darwin build?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is needed for me because I don't have access to macos so I rely on ofBorg results.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then it doesn't need to be in the commit. You can request the help of @NixOS/darwin-maintainers to fix the remaining Darwin issues.

@wegank wegank marked this pull request as draft February 24, 2024 23:35
@wegank
Copy link
Member

wegank commented Feb 24, 2024

I guess this is unlikely to work, since building the JDK from source on Darwin requires Xcode. Also, openjdk is actually zulu on Darwin for this, so jdk.overrideAttrs wouldn't produce what you want.

@rollf
Copy link
Contributor Author

rollf commented Feb 26, 2024

I guess this is unlikely to work, since building the JDK from source on Darwin requires Xcode. Also, openjdk is actually zulu on Darwin for this, so jdk.overrideAttrs wouldn't produce what you want.

Ah, good hint. Thank you.

@rollf
Copy link
Contributor Author

rollf commented Feb 27, 2024

This PR was motivated by issue #290341 ("Corretto build fails on macos"). Corretto was originally added (by me) in PR #263736 ( follow-up was #272226, Corretto is Amazon's Java distribution). It seems that that the original PR never went through ofBorg's testing of the compilation on Darwin (at least I can't see anything in the PR Conversation).

Currently, Corretto can't build on Darwin. I do not have access to a Mac so I can't work in this.
I suspect the buildPhase might be okay (now) but installPhase not.
In this (draft) PR, I purely speculated how things could work based on the feedback from @atl-nick in #290341.
@wegank pointed out, that the current approach might not work at all since Darwin's JDK is zulu by default, not openjdk.

For reference, here is the gradle task that I think would build the tar.gz'ed jdk on Darwin.

@NixOS/darwin-maintainers Do you mind having a look into this?

@wegank
Copy link
Member

wegank commented Feb 27, 2024

This PR was motivated by issue #290341 ("Corretto build fails on macos"). Corretto was originally added (by me) in PR #263736 ( follow-up was #272226, Corretto is Amazon's Java distribution). It seems that that the original PR never went through ofBorg's testing of the compilation on Darwin (at least I can't see anything in the PR Conversation).

As indicated, #263736 also failed to build on darwin: https://github.com/NixOS/nixpkgs/runs/18953283987

I guess the reviewers just ignored the neutral checks...

Currently, Corretto can't build on Darwin. I do not have access to a Mac so I can't work in this. I suspect the buildPhase might be okay (now) but installPhase not.

The build phase is not OK: https://github.com/NixOS/nixpkgs/pull/290808/checks?check_run_id=22019011776

@drupol
Copy link
Contributor

drupol commented Mar 1, 2024

@GrahamcOfBorg build corretto11

@pcasaretto
Copy link
Contributor

Result of nixpkgs-review pr 290808 run on aarch64-darwin 1

@pcasaretto
Copy link
Contributor

pcasaretto commented Mar 1, 2024

Other than building locally, how can I help you @rollf ?

@pcasaretto
Copy link
Contributor

Here's the run log for nix-build -A corretto17
https://gist.github.com/pcasaretto/73c47ed813d8e787fdd96915e94ccebf

@rollf
Copy link
Contributor Author

rollf commented Mar 1, 2024

Hi @pcasaretto , thanks for chiming in. Well yes, I think fixing the build locally would be great. I can only guess from here. Thanks for adding the run log. I am blindly guessing: Maybe adding xcode would do the trick, maybe adding Foundation? Some hints from my side:

Mind the comment above, too.

@pcasaretto
Copy link
Contributor

Some progress:
I was able to fix the configure: error: Invalid SDK or SYSROOT path, dependent framework headers not found error with the following:

  # dontConfigure = true;
  configurePhase = ''
    runHook preConfigure

    bash configure --with-xcode-path=$(xcode-select -p)

    runHook postConfigure
  '';

Then I ran into an error for a missing "zip" executable which was easy to resolve adding "zip" to "nativeBuildInputs".
The current error is:

checking for xattr... [not found]
configure: error: Could not find required tool for XATTR

@pcasaretto
Copy link
Contributor

pcasaretto commented Mar 1, 2024

It seems xattr is a mac specific CLI tool and it is not available at the PATH during build time.
What's the nix recommended course of action?

❯ nix-shell -A corretto17 --pure

[nix-shell:~/src/github.com/NixOS/nixpkgs]$ which xattr
which: no xattr in (/nix/store/8rxm4jzw1dddm53rpc2zdqgafadn7d5n-bash-interactive-5.2-p21/bin:/nix/store/sp2zc9qkdc3y8289y04121qysndhwpax-unzip-6.0/bin:/nix/store/cj4knn6zm57bgxqm7xyspyyf65inzq43-zulu-ca-jdk-17.0.10/bin:/nix/store/0njllzg3kn3s552wy7blnvhxkyb3l0ja-gradle-7.6.3/bin:/nix/store/dsqzqql434x72yla2r9ym8m3s2zhzwvr-rsync-3.2.7/bin:/nix/store/qpd69yfix5psmsbv251ky18mc1lxnx70-coreutils-9.4/bin:/nix/store/bh3dlarp8jl8lgx4c6jzq10rxmcqdds2-zip-3.0/bin:/nix/store/fxx9fci30k4jwn60nk686q9zazgrk9s0-autoconf-2.72/bin:/nix/store/x6i5r0kvqrg848nicpwbzyih70brxj69-which-2.21/bin:/nix/store/ds256fb8aqfh3wpy9kzfhszlf6hd8ajc-xcodebuild-0.1.2-pre/bin:/nix/store/vma6hzcw19fbpfjll4yk33k52pw5wn0x-Toolchains/XcodeDefault.xctoolchain/bin:/nix/store/k687y4hiraslz65qz8pli1wb5wmcabvn-clang-wrapper-16.0.6/bin:/nix/store/3ijvz3w7ka2wfl3yk77r9c79c0fzb9j9-clang-16.0.6/bin:/nix/store/cwkgbzhwdkjp4sff8m3hbqisd7z333cn-cctools-binutils-darwin-wrapper-16.0.6-973.0.1/bin:/nix/store/79fqcmdsj5prcn7xcmfaj6i0qcrz9s13-cctools-binutils-darwin-16.0.6-973.0.1/bin:/nix/store/qpd69yfix5psmsbv251ky18mc1lxnx70-coreutils-9.4/bin:/nix/store/lb9k8p8c8bf8b5v4gayzyx656a8n9cbp-findutils-4.9.0/bin:/nix/store/ri18k5b34qlapg1908afz4z51z1b3fbl-diffutils-3.10/bin:/nix/store/g44k88l2xg41bgsdhsw609smypmiz6j7-gnused-4.9/bin:/nix/store/av92p4b35n68p837dqq6jq6gjdk6s19q-gnugrep-3.11/bin:/nix/store/spskfl77py9hyvh3f9sjsqcrbsaiprh0-gawk-5.2.2/bin:/nix/store/ivklia9w69144iys517bvbc0d8paj2ai-gnutar-1.35/bin:/nix/store/m7bk558n8sli5z52splzgvrih5gasbvc-gzip-1.13/bin:/nix/store/d6ki959pnsa3w8iydkfjcjrggyplk66i-bzip2-1.0.8-bin/bin:/nix/store/mfygsgqn2jnm14918y96rb7c9avvnpk0-gnumake-4.4.1/bin:/nix/store/0j90xxj4in0yk2dp7mpvsm8jqd9mrbs3-bash-5.2p26/bin:/nix/store/1s37mqrr4szz2r3fk4hm9rzzgk36jyk6-patch-2.7.6/bin:/nix/store/v4l2p3sm90qyfsfs7kyw1xb629f93z53-xz-5.4.6-bin/bin:/nix/store/69pprys9925xm0byrcb3b3nk73a7lszw-file-5.45/bin)

@pcasaretto
Copy link
Contributor

Oh, wait, there's a package for it pkgs/os-specific/darwin/xattr/default.nix

@pcasaretto
Copy link
Contributor

Adding "xattr" and "fileset" lead me to:

configure: error: XCode tool 'metal' neither found in path nor with xcrun

Latest build log: https://gist.github.com/pcasaretto/c7f284a18c13e3b3213d99d6b9b3ab3f
Current wip commit: pcasaretto@e2534cf

Will try to resume over the weekend.

@pcasaretto
Copy link
Contributor

Funny thing is that the docs mention full XCode is NOT required but there is a direct dependency on the "metal" executable.

@rollf
Copy link
Contributor Author

rollf commented Mar 4, 2024

@pcasaretto Thanks for your efforts! I invited you to my fork. Could you share your achievements so far within the corretto-macos branch? This way, we have a common understanding.

One thing I have thought about: What about not forwarding, say, openjdk11 from corretto11.nix to mk-corretto.nix but directely using zulu11 if on Darwin?

@pcasaretto
Copy link
Contributor

Sure!
Just a quick note before I get to it:

Adding a trace for what package is being used for building, for example, correto17 on darwin gives me zulu-ca-jdk-17.0.10. So if I understand correctly, it's already picking up the correct base package.

@pcasaretto
Copy link
Contributor

pcasaretto commented Mar 5, 2024

I managed to advance a little further but now I'm stuck at clang not finding the c++ stdlib files.
Here's the most recent build log https://gist.github.com/pcasaretto/76ce7283b31197b7729597e1474f3e4f

@pcasaretto
Copy link
Contributor

Upon further investigation (using the NIX_DEBUG env var) I found that apparently, the correct instructions are being given to clang. However, it cannot find the proper xnu headers it needs for my current architecture (arm64).

+ echo 'extra flags after to /nix/store/3ijvz3w7ka2wfl3yk77r9c79c0fzb9j9-clang-16.0.6/bin/clang++:'                                                                           
extra flags after to /nix/store/3ijvz3w7ka2wfl3yk77r9c79c0fzb9j9-clang-16.0.6/bin/clang++:                                                                                    
+ printf '  %q\n' -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -B/nix/store/jy1rsx8kz6wd11kcj5pc8wvh344x1qfr-libSystem-11.0.0/lib/ -idirafter /nix/store/jy1rsx8kz6wd11kcj5pc8wvh344x
1qfr-libSystem-11.0.0/include -B/nix/store/panp8x4v0cn4zs406jfqcgv1g5sjga1r-clang-16.0.6-lib/lib -arch arm64 -resource-dir=/nix/store/k687y4hiraslz65qz8pli1wb5wmcabvn-clang-w
rapper-16.0.6/resource-root -B/nix/store/k687y4hiraslz65qz8pli1wb5wmcabvn-clang-wrapper-16.0.6/bin/ -frandom-seed=f43ap8n0j9 -isystem /nix/store/jg1l0kac2mrs9f2khyzzq5ra8mwa8
26j-zulu-ca-jdk-11.0.22/include -isystem /nix/store/vma6hzcw19fbpfjll4yk33k52pw5wn0x-Toolchains/XcodeDefault.xctoolchain/include -isystem /nix/store/flkpbg20pfzfa9f2lwzrzjl71
8i2ccw7-python3-3.11.7/include -isystem /nix/store/fr3lw42b0r8h9yv1p0zsfhvj5qkbplrg-cups-2.4.7-dev/include -isystem /nix/store/w37jkdzj6cwz0c6xawvp9bzsyqyqyibg-gmp-with-cxx-6
.3.0-dev/include -isystem /nix/store/44njikmaxxn4n4q8v5bxsj2v6ysq69qv-xnu-7195.50.7.100.1/include -iframework /nix/store/44njikmaxxn4n4q8v5bxsj2v6ysq69qv-xnu-7195.50.7.100.1/
Library/Frameworks -isystem /nix/store/ydfb1m5h1lcghpvs2hmv9686z008paij-libcxx-16.0.6-dev/include -isystem /nix/store/3g6shmh8g2chzywmyx6ls9i1rhz415ki-libcxxabi-16.0.6-dev/in
clude -isystem /nix/store/jp3f1d5scfknawlp5d7f6wy92mhq0p49-compiler-rt-libc-16.0.6-dev/include -iframework /nix/store/ns3i9j479s5fngbfakl546bb2bykwdza-apple-framework-CoreFou
ndation-11.0.0/Library/Frameworks -isystem /nix/store/aacafvhpd3zpr38fnijl652q1qyhgi3p-libobjc-11.0.0/include -isystem /nix/store/jg1l0kac2mrs9f2khyzzq5ra8mwa826j-zulu-ca-jdk
-11.0.22/include -isystem /nix/store/vma6hzcw19fbpfjll4yk33k52pw5wn0x-Toolchains/XcodeDefault.xctoolchain/include -isystem /nix/store/flkpbg20pfzfa9f2lwzrzjl718i2ccw7-python3
-3.11.7/include -isystem /nix/store/fr3lw42b0r8h9yv1p0zsfhvj5qkbplrg-cups-2.4.7-dev/include -isystem /nix/store/w37jkdzj6cwz0c6xawvp9bzsyqyqyibg-gmp-with-cxx-6.3.0-dev/includ
e -isystem /nix/store/44njikmaxxn4n4q8v5bxsj2v6ysq69qv-xnu-7195.50.7.100.1/include -iframework /nix/store/44njikmaxxn4n4q8v5bxsj2v6ysq69qv-xnu-7195.50.7.100.1/Library/Framewo
rks -isystem /nix/store/ydfb1m5h1lcghpvs2hmv9686z008paij-libcxx-16.0.6-dev/include -isystem /nix/store/3g6shmh8g2chzywmyx6ls9i1rhz415ki-libcxxabi-16.0.6-dev/include -isystem 
/nix/store/jp3f1d5scfknawlp5d7f6wy92mhq0p49-compiler-rt-libc-16.0.6-dev/include -iframework /nix/store/ns3i9j479s5fngbfakl546bb2bykwdza-apple-framework-CoreFoundation-11.0.0/
Library/Frameworks -isystem /nix/store/aacafvhpd3zpr38fnijl652q1qyhgi3p-libobjc-11.0.0/include -isystem /nix/store/ydfb1m5h1lcghpvs2hmv9686z008paij-libcxx-16.0.6-dev/include/
c++/v1 -isystem /nix/store/3g6shmh8g2chzywmyx6ls9i1rhz415ki-libcxxabi-16.0.6-dev/include/c++/v1 

And when I forced that to happen using:

env.NIX_CFLAGS_COMPILE="-I${darwin.xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers"

that messed up the order of the imports, triggering this code https://reviews.llvm.org/D131441

@pcasaretto
Copy link
Contributor

Tried a couple of things like:

      export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${darwin.apple_sdk.frameworks.Kernel}/Library/Frameworks/Kernel.framework/Versions/A/Headers"

But I always end up without ptrauth.h or the stdlib.
Hey @tjni @toonn, saw you have recently worked on somewhat similar issues. Can you help? 😃

@tricktron
Copy link
Member

@pcasaretto It looks like that ptrauth is baked into llvm but it is not yet upstreamed: #188322 (comment) and here is the big pull request which might soon land: llvm/llvm-project#65996

As a result, it is currently not possible to create an aarch64-darwin source build because we need to wait until the pr lands in llvm and then in nixpkgs.

I was once in the same situation as you were and I admire your persistence and commitment to get this source build working. However, I want to raise the question if it does not make more sense to just provide binary builds on darwin because

  • building projects which rely on Xcode is flaky and difficult to maintain
  • building on aarch64 directly is not recommended by the upstream docs

Finally, I don't want to discourage you completely and therfore you could try building it for x86_64-darwin on an aarch64 machine with nix-build -A corretto11 --system x86_64-darwin.

@rollf
Copy link
Contributor Author

rollf commented Mar 7, 2024

Thanks once again @pcasaretto for your work here. Thank you, @tricktron, also for your feedback.

@pcasaretto
Copy link
Contributor

That makes a lot of sense. Thanks!
@rollf should we wait then?

@rollf
Copy link
Contributor Author

rollf commented Mar 11, 2024

@pcasaretto I'd personally rather wait and see whether corretto could be build by us entirely instead of providing binary builds. While the "corretto" docs say that aarch64 is unsupported, aarch64 macos builds are actually provided. My impression from previously working with the corretto code base is that some of the docs are not up to date - corretto is a fork but the docs sometimes still assume jdk.

I'm think now that I could try to build myself with --system x86_64-darwin (which I wasn't aware of). I hope I find some time to do this.

@pcasaretto
Copy link
Contributor

Using that flag I was able to advance further into the buildPhase.
However, I've a met a new blocking issue.
It appears nix build is tapping into my local environment to fetch Apple related framework files.

In file included from /private/tmp/nix-build-corretto-11.0.20.9.1.drv-2/source/installers/mac/tar/corretto-build/buildRoot/src/java.base/macosx/native/libjava/HostLocaleProvi
derAdapter_md.c:28:                                                                                                                                                           
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/He
aders/CoreFoundation.h:76:                                                                                                                                                    
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/He
aders/CFPropertyList.h:18:                                                                                                                                                    
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/He
aders/CFStream.h:16:                                                                                                                                                          
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1218:83:
 error: expected ','                                                                                                                                                          
    kCFURLBookmarkCreationWithSecurityScope API_AVAILABLE(macos(10.7), macCatalyst(13.0))  API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 11 ), // Mac OS X 10.7.3 and later, 
include information in the bookmark data which allows the same sandboxed process to access the resource after being relaunched

I thought nix builds were pure?

Full log: https://gist.github.com/pcasaretto/e2aed869acd7ac07f0dff44f808368bc

@pcasaretto
Copy link
Contributor

invoking clang by itself shows an environment where the the Apple Frameworks seem to be configured correctly.

$ nix-shell -A corretto11  --system x86_64-darwin --pure --command "clang -Xlinker -v"
@(#)PROGRAM:ld  PROJECT:ld64-609
BUILD 00:00:00 Jan  1 1980
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
	/nix/store/apsgmz95l6l36z7irdnvvb6l0gjc2rcg-zulu-ca-jdk-11.0.22/lib
	/nix/store/pwr22740f2pv36q5g28l1gjdg1bw43zm-python3-3.11.7/lib
	/nix/store/dvb8a6g3vmzcckmdjgbcnkw7vpy5df0h-gmp-with-cxx-6.3.0/lib
	/nix/store/sxjpax8c20gvnphwxdn61wrlvk5np61z-cups-2.4.7-lib/lib
	/nix/store/j00fvbc23iccxf0x0925dkpp8zg4gzw1-objc4-709.1/lib
	/nix/store/vj3mzjyppyjqpqs6k0v9hyr80abmp1ay-libcxx-16.0.6/lib
	/nix/store/jgzbk5v82s2da4fqd4pjnphpb0c9r351-libcxxabi-16.0.6/lib
	/nix/store/4zx1dv50bbj63z5nrh3wjhz22np1f862-compiler-rt-libc-16.0.6/lib
	/nix/store/apsgmz95l6l36z7irdnvvb6l0gjc2rcg-zulu-ca-jdk-11.0.22/lib
	/nix/store/pwr22740f2pv36q5g28l1gjdg1bw43zm-python3-3.11.7/lib
	/nix/store/dvb8a6g3vmzcckmdjgbcnkw7vpy5df0h-gmp-with-cxx-6.3.0/lib
	/nix/store/sxjpax8c20gvnphwxdn61wrlvk5np61z-cups-2.4.7-lib/lib
	/nix/store/j00fvbc23iccxf0x0925dkpp8zg4gzw1-objc4-709.1/lib
	/nix/store/vj3mzjyppyjqpqs6k0v9hyr80abmp1ay-libcxx-16.0.6/lib
	/nix/store/jgzbk5v82s2da4fqd4pjnphpb0c9r351-libcxxabi-16.0.6/lib
	/nix/store/4zx1dv50bbj63z5nrh3wjhz22np1f862-compiler-rt-libc-16.0.6/lib
	/nix/store/bj09naxfr523dj1a9namyy39x6ql94cj-Libsystem-1238.60.2/lib
	/nix/store/9bi45sw4fpambgnkakixzl19lpv3ywnz-clang-16.0.6-lib/lib
	/nix/store/vj3mzjyppyjqpqs6k0v9hyr80abmp1ay-libcxx-16.0.6/lib
Framework search paths:
	/nix/store/vd60gxr6sqqmrpajzdx8aly6fha951p9-apple-framework-Foundation/Library/Frameworks
	/nix/store/ns33cjy120wm6l5g27hsgg0iyc4cb0ds-apple-framework-ApplicationServices/Library/Frameworks
	/nix/store/gjxdxkifj9yvhy2zpivyfncg6sbsqmkk-apple-framework-CoreGraphics/Library/Frameworks
	/nix/store/ndmvnxcs6419g1wg1k3gxsafad6rm9n3-apple-framework-Accelerate/Library/Frameworks
	/nix/store/1qal72q8f2cw9rw0napbhxs42zkkg8fm-apple-framework-CoreWLAN/Library/Frameworks
	/nix/store/dkc1wn6xwr3hlfcg44yzplyadwr2yyqi-apple-framework-SecurityFoundation/Library/Frameworks
	/nix/store/h0ac3963fhasj1548kj902sp4a6kkbgy-apple-framework-IOBluetooth/Library/Frameworks
	/nix/store/wnbbgmcchk2b00l43j6lz16bywvmm0s6-apple-framework-CoreBluetooth/Library/Frameworks
	/nix/store/4cbvfzh59s46vim2r3br406fq6kz7wvz-apple-framework-IOKit/Library/Frameworks
	/nix/store/7psg1jx4i0827rxjhlg3544873dvdfix-apple-framework-IOSurface/Library/Frameworks
	/nix/store/45c3f7l13n6y90yrmhrgi0bmgbsqzg5v-apple-framework-SystemConfiguration/Library/Frameworks
	/nix/store/flyjwndm79znl4dwnf47cwip8744wwwd-apple-framework-Security/Library/Frameworks
	/nix/store/j74y27x0rd9xip9kp5skrqc8458my284-apple-framework-CoreServices/Library/Frameworks
	/nix/store/qcnl8j4j6k5vb7zgxqkihpb5sg799yp5-apple-framework-CFNetwork/Library/Frameworks
	/nix/store/z0ga4hppjr5gw91q7zglapmxwfaf8k6c-apple-framework-CoreAudio/Library/Frameworks
	/nix/store/3xyj7fx38bgnldiryvp55l923d9dv7m0-apple-framework-CoreData/Library/Frameworks
	/nix/store/35arz20x269wb9fzx4gfmf8h5m5c61pw-apple-framework-CoreFoundation/Library/Frameworks
	/nix/store/cg2jgvmahpv5a3ivv2ml8gigyyv2bimk-apple-framework-DiskArbitration/Library/Frameworks
	/nix/store/xdzz642ahnrwwvl5iv0gagvp3xh6l659-apple-framework-NetFS/Library/Frameworks
	/nix/store/8172wja2zd6pksnm985dr5pabblbnpgv-apple-framework-OpenDirectory/Library/Frameworks
	/nix/store/k6i6nbr2ffbx90mvrh2cswwxsia6zwxs-apple-framework-ServiceManagement/Library/Frameworks
	/nix/store/pqp8vp0r5jkbiqdpvcpx8i7hzw5sw8qz-apple-framework-CoreText/Library/Frameworks
	/nix/store/sckf64vhasnwpq5yciwv8l2pd9dlap83-apple-framework-ImageIO/Library/Frameworks
	/nix/store/a55b69y2gdzkd4i4cnjx6agyq0p2bsav-apple-framework-CoreFoundation/Library/Frameworks
	/nix/store/vd60gxr6sqqmrpajzdx8aly6fha951p9-apple-framework-Foundation/Library/Frameworks
	/nix/store/ns33cjy120wm6l5g27hsgg0iyc4cb0ds-apple-framework-ApplicationServices/Library/Frameworks
	/nix/store/gjxdxkifj9yvhy2zpivyfncg6sbsqmkk-apple-framework-CoreGraphics/Library/Frameworks
	/nix/store/ndmvnxcs6419g1wg1k3gxsafad6rm9n3-apple-framework-Accelerate/Library/Frameworks
	/nix/store/1qal72q8f2cw9rw0napbhxs42zkkg8fm-apple-framework-CoreWLAN/Library/Frameworks
	/nix/store/dkc1wn6xwr3hlfcg44yzplyadwr2yyqi-apple-framework-SecurityFoundation/Library/Frameworks
	/nix/store/h0ac3963fhasj1548kj902sp4a6kkbgy-apple-framework-IOBluetooth/Library/Frameworks
	/nix/store/wnbbgmcchk2b00l43j6lz16bywvmm0s6-apple-framework-CoreBluetooth/Library/Frameworks
	/nix/store/4cbvfzh59s46vim2r3br406fq6kz7wvz-apple-framework-IOKit/Library/Frameworks
	/nix/store/7psg1jx4i0827rxjhlg3544873dvdfix-apple-framework-IOSurface/Library/Frameworks
	/nix/store/45c3f7l13n6y90yrmhrgi0bmgbsqzg5v-apple-framework-SystemConfiguration/Library/Frameworks
	/nix/store/flyjwndm79znl4dwnf47cwip8744wwwd-apple-framework-Security/Library/Frameworks
	/nix/store/j74y27x0rd9xip9kp5skrqc8458my284-apple-framework-CoreServices/Library/Frameworks
	/nix/store/qcnl8j4j6k5vb7zgxqkihpb5sg799yp5-apple-framework-CFNetwork/Library/Frameworks
	/nix/store/z0ga4hppjr5gw91q7zglapmxwfaf8k6c-apple-framework-CoreAudio/Library/Frameworks
	/nix/store/3xyj7fx38bgnldiryvp55l923d9dv7m0-apple-framework-CoreData/Library/Frameworks
	/nix/store/35arz20x269wb9fzx4gfmf8h5m5c61pw-apple-framework-CoreFoundation/Library/Frameworks
	/nix/store/cg2jgvmahpv5a3ivv2ml8gigyyv2bimk-apple-framework-DiskArbitration/Library/Frameworks
	/nix/store/xdzz642ahnrwwvl5iv0gagvp3xh6l659-apple-framework-NetFS/Library/Frameworks
	/nix/store/8172wja2zd6pksnm985dr5pabblbnpgv-apple-framework-OpenDirectory/Library/Frameworks
	/nix/store/k6i6nbr2ffbx90mvrh2cswwxsia6zwxs-apple-framework-ServiceManagement/Library/Frameworks
	/nix/store/pqp8vp0r5jkbiqdpvcpx8i7hzw5sw8qz-apple-framework-CoreText/Library/Frameworks
	/nix/store/sckf64vhasnwpq5yciwv8l2pd9dlap83-apple-framework-ImageIO/Library/Frameworks
	/nix/store/a55b69y2gdzkd4i4cnjx6agyq0p2bsav-apple-framework-CoreFoundation/Library/Frameworks
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

@pcasaretto
Copy link
Contributor

pcasaretto commented Mar 11, 2024

The problem is taming this part of the configure phase https://github.com/corretto/corretto-11/blob/22d3ba74941d48a775ef44c69e1a8e92d099cb8e/make/autoconf/basic.m4#L241-L308
This line in particular seems troublesome because it checks for a very specific path that I think will get included via clang wrapper headers.
Can we use something like substituteInPlace to get rid of it?

@rollf
Copy link
Contributor Author

rollf commented Mar 12, 2024

The particular error you have seems to stem from mixing SDKs.

(FYI: Your two links link to basic.m4 and toolchain.m4 but it reads like you intended to link to the same file.)

From the code you linked, some ideas: Maybe run with --wity-sysroot (don't know what this would be, though). Do we maybe need xcode additionally to xcbuild?

Can you also share your current state (i.e push)?

@pcasaretto
Copy link
Contributor

It makes sense that they were mixed, part of the build used my machine's actual XCode.app.
I've deleted it to reduce the number of moving parts.
Pushed the current state.

@pcasaretto
Copy link
Contributor

Do we maybe need xcode additionally to xcbuild?

I think they are mutually exclusive. The experience of using Xcode with nixpkgs is really poor (it's not nixpkgs fault).
We should only resort to Xcode if we can't get the build going with xcbuild.

@pcasaretto
Copy link
Contributor

pcasaretto commented Mar 12, 2024

About --with-sysroot, I can't find a path that would satisfy this test https://github.com/corretto/corretto-11/blob/develop/make/autoconf/basic.m4#L301

Using "--with-sysroot=${darwin.apple_sdk.frameworks.Foundation}" gets me close but there's no "System" directory in that path, so the test fails.

$ ls /nix/store/vd60gxr6sqqmrpajzdx8aly6fha951p9-apple-framework-Foundation/Library/Frameworks/Foundation.framework/Headers/Foundation.h 
/nix/store/vd60gxr6sqqmrpajzdx8aly6fha951p9-apple-framework-Foundation/Library/Frameworks/Foundation.framework/Headers/Foundation.h

@pcasaretto
Copy link
Contributor

Some good news! It tooks a customized xnu derivation and some extra dependencies but I think I can see the light at the end of the tunnel.
Current build log mentions failures in unzipping

@pcasaretto
Copy link
Contributor

Made some progress but still stuck on the zip error.

@rollf
Copy link
Contributor Author

rollf commented Mar 22, 2024

Mh, that zip error is strange. Maybe you could have a look into the failed build folder (--keep-failed) and check the file/folder structure. Maybe some file/folder does actually not exists.

It looks like the osxsecurity & the zip libs should have been built both, though:

image

@pcasaretto
Copy link
Contributor

As it turns out, that zip error is misleading. It seems when an error occurs the build tries to update or delete support/src.zip and fails to do so.
Investigating the make file the error pointed to I noticed several missing dependencies.
I've added them and the build advanced a little.
The current error mentions a problem building libjimage.diz. It seems the dependency for that should come included with the zulu package. So maybe it's just a configuration problem?

Most recent build log

@rollf rollf mentioned this pull request Apr 26, 2024
13 tasks
@rollf
Copy link
Contributor Author

rollf commented Apr 29, 2024

@pcasaretto I have added corretto21 (see PR) and recycled your idea of forwarding dedicated arguments to gradle. Thus the merge conflicts here I guess.

@pcasaretto
Copy link
Contributor

I am stepping down from this. Vacation's over.

@rollf
Copy link
Contributor Author

rollf commented May 21, 2024

@pcasaretto Thank your very much for your work here.

I had already ping'ed the darwin maintainers above so I don't want to do this again here. If anyone wants to contribute, feel free!

@atl-nick
Copy link

atl-nick commented Aug 20, 2024

Personally, I think it would be worth considering @tricktron's suggestion and packaging the binaries for macos. It seems like even if we can get a source build working it's likely to be flaky and a pain to maintain.

@rollf rollf mentioned this pull request Sep 26, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants