-
Notifications
You must be signed in to change notification settings - Fork 1.7k
GraalVM 23.0.0's native-image is cleaning the environment before calling C compiler #7502
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
Comments
Thank you for reporting this, we'll take a look into it shortly |
Hi, Could you please provide more specific steps to reproduce the issue? I've created the CC file but it wasn't executed, there is no file under |
You need to create a
Create a new file in
|
I think the script is missing the execution bit:
This should work. |
Just to make sure, before running GraalVM, run |
@oubidar-Abderrahim Any updates on this issue? I have a very strong suspicious this is also affecting Linux systems. |
Unfortunately, I cannot reproduce the issue. after building the image I compared the Env variable in |
Maybe related? #7981 |
I'll close this issue for now as not reproducible. If the suggestion from #7981 is not solving the issue, and you can provide a more reliable reproducer, please reopen or create a new issue for it and we'll check it again. Thank you |
Thanks @oubidar-Abderrahim, using Do we have any idea for how long this environment variable will be supported? |
We don't have a specific date yet, but I would suggest using |
Would it be possible to add an env var wildcard? I have like 20+ environment variables that I'm capturing at build time starting with |
We also need to inject a bunch of environment variables. |
Describe the issue
I am working in bumping GraalVM package to the https://github.com/graalvm/graalvm-ce-builds/releases/tag/jdk-21.0.0 inside nixpkgs (see PR) and bumped in the following issue.
Using the latest stable release, it seems
native-image
is cleaning the environment variables before calling the C compiler (cc
). I did the following test by creating a small wrapper script forcc
that basically does:And this is the result:
Builder environment (I removed a few things since Nix exports all the derivation attributes as environmental variables, so if I put everything here it would be confusing):
CC environment:
Why is this an issue? In Nix we don't have the libraries in their expected places, so we need to give some help for the compiler to find everything. We do this by wrapping the C compiler and exporting some environmental variables that allows the compiler to figure out where everything is. For example
NIX_CFLAGS_COMPILE
andNIX_LDFLAGS
. By removing those environment variables the compiler can't find the critical libraries, resulting in the following issue we are seeing:As you can see,
Foundation/Foundation.h
is not found (this build was done in anx86_64
MacOS environment). If you look at theNIX_COMPILE_FLAGS
andNIX_LDFLAGS
, those includes the incantations that the C compiler needs to add to find the libraries. I created a workaround where we re-inject the expectedNIX_COMPILE_FLAGS
andNIX_LDFLAGS
inside acc
wrapper, and this was sufficient to get it to build again. However this is ugly and fragile. Also, we didn't need any of those things until GraalVM 22.3.1, so I imagine this is a recent change done in the 23.0.0 release.If the environment cleaning in the C compiler is proposital to workaround some other issue, can we have some flag to disable this behavior or at least some way were we can add environment variables to the allowlist (so they would be re-added to the C compiler environment)? Keep in mind that we always run a build inside a proper sandbox, so the issue where some random environment variables is breaking builds (something that I imagine was the reason for this change) wouldn't affect us.
Steps to reproduce the issue
cc
and put it before anything else in yourPATH
native-image
cat /tmp/environment
and compare with your current environment. You will see that it is missing tons of environment variablesDescribe GraalVM and your environment:
More details
N/A
The text was updated successfully, but these errors were encountered: