On Wed, 19 Mar 2025 18:28:50 GMT, Erik Joelsson <er...@openjdk.org> wrote:

> The `EXTRA_[C|CXX]FLAGS` variables are not meant to be parameters to 
> SetupNativeCompilation

Actually, the content of EXTRA_[C|CXX]FLAGS is hidden (and mixed together) 
inside the `JVM_CFLAGS` and get passed to as a parameter to 
`SetupNativeCompilation` eventually. The diff is whether we want to pass them 
implicitly (**base**) or explicitly (**patch**).
The call sequence is:

1. Set up **JVM_CFLAGS** and append **EXTRA_CXXFLAGS** 
(make/autoconf/flags-cflags.m4#893) ->
2. Update **JVM_CFLAGS** and append **EXTRA_CFLAGS** 
(make/hotspot/lib/JvmFlags.gmk#L89) ->
3. Build libjvm ->
4. SetupJdkLibrary (pass **JVM_CFLAGS** as a parameter called **CFLAGS**, 
make/hotspot/lib/CompileJvm.gmk#L172) -> 
5. SetupJdkNativeCompilation (make/common/JdkNativeCompilation.gmk#L477) -> 
6. SetupNativeCompilation (make/common/JdkNativeCompilation.gmk#L456) ->
7. SetupCompilerFlags (set CXXFLAGS to **JVM_CFLAGS** now, 
make/common/NativeCompilation.gmk#L159, make/common/native/Flags.gmk#L131); 
CreateCompiledNativeFile (BASE_CXXFLAGS contains **JVM_CFLAGS** now, 
make/common/NativeCompilation.gmk#L179) ->
8. Compile C++ with BASE_CXXFLAGS that contains **JVM_CFLAGS** 
(make/common/native/CompileFile.gmk#L162)

> Wouldn't just the change in JvmFlags.gmk be enough to solve your issue?

No, it seems not doable. 
As mentioned above in the step 1 and 2, **JVM_CFLAGS** contains both 
EXTRA_CXXFLAGS and EXTRA_CFLAGS at that time, when calling 
SetupNativeCompilation, there is no information left about which flags were 
from EXTRA_[C|CXX]FLAGS and we are unable to do filter-out for C vs C++ files 
using corresponding flags.  So, it is a dilemma, if we want to keep the 
parameters list of SetupNativeCompilation clean (untouched) we would have 
EXTRA_[C|CXX]FLAGS mixed together for compiling C and C++ files. Any other idea 
here please?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/24115#issuecomment-2738738973

Reply via email to