How to build hotspot jtreg test JNI with specific CFLAGS?
Erik Joelsson
erik.joelsson at oracle.com
Thu Aug 23 14:39:25 UTC 2018
Hello Severin,
This does indeed look like the correct fix and I agree that the
OPTIMIZATION level should be customizeable like this for test libraries.
/Erik
On 2018-08-06 03:29, Severin Gehwolf wrote:
> Hi,
>
> On Mon, 2018-08-06 at 09:52 +0200, Severin Gehwolf wrote:
>>>> I'm trying to get a JNI library used for testing to be compiled with
>>>> certain CFLAGS. In particular, I'm trying to get it compiled on a GCC
>>>> platform with '-fomit-frame-pointer' and/or '-fomit-frame-pointer -O3'.
>>>> The patch currently looks like this:
>>>>
>>>> diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk
>>>> --- a/make/test/JtregNativeHotspot.gmk
>>>> +++ b/make/test/JtregNativeHotspot.gmk
>>>> @@ -139,6 +139,13 @@
>>>> -I$(VM_TESTBASE_DIR)/nsk/share/native \
>>>> -I$(VM_TESTBASE_DIR)/nsk/share/jni
>>>>
>>>> +NO_FRAMEPOINTER_CFLAGS :=
>>>> +ifeq ($(OPENJDK_TARGET_OS),linux)
>>>> + NO_FRAMEPOINTER_CFLAGS := -O3 -fomit-frame-pointer
>>>> +endif
>>>> +
>>>> +BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libNoFramePointer := $(NO_FRAMEPOINTER_CFLAGS)
>>>> +
>>>> BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libProcessUtils := $(VM_SHARE_INCLUDES)
>>>>
>>>> BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libThreadController := $(NSK_MONITORING_INCLUDES)
>>>>
>>>> When I look at the compile command line this produces with 'make run-test', I see this:
>>>>
>>>> $ cat ./build/linux-x86_64-normal-server-release/support/test/hotspot/jtreg/native/support/libNoFramePointer/libNoFramePointer.o.cmdline
>>>> /usr/bin/gcc -I/disk/openjdk/upstream-sources/openjdk-head/build/linux-x86_64-normal-server-release/support/modules_include/java.base -I/disk/openjdk/upstream-sources/openjdk-head/build/linux-x86_64-normal-server-release/support/modules_include/java.base/linux -I/disk/openjdk/upstream-sources/openjdk-head/src/java.base/share/native/libjava -I/disk/openjdk/upstream-sources/openjdk-head/src/java.base/unix/native/libjava -I/disk/openjdk/upstream-sources/openjdk-head/src/hotspot/share/include -I/disk/openjdk/upstream-sources/openjdk-head/src/hotspot/os/posix/include -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DLINUX -DNDEBUG -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 -fno-strict-aliasing -m64 -D_LITTLE_ENDIAN -DARCH='"amd64"' -Damd64 -D_LP64=1 -fno-omit-frame-pointer -fno-delete-null-pointer-checks -fno-lifetime-dse -fPIC -O3 -fomit-frame-pointer -g -O2 -DTHIS_FILE='""' -c -MMD -MF /disk/openjdk/upstream-sources/openjdk-head/build/linux-x86_64-normal-server-release/support/test/hotspot/jtreg/native/support/libNoFramePointer/libNoFramePointer.d -o /disk/openjdk/upstream-sources/openjdk-head/build/linux-x86_64-normal-server-release/support/test/hotspot/jtreg/native/support/libNoFramePointer/libNoFramePointer.o /disk/openjdk/upstream-sources/openjdk-head/test/hotspot/jtreg/serviceability/sa/libNoFramePointer.c
>>>>
>>>> The command line has '-O3 -fomit-frame-pointer -g -O2' in that order.
>>>> This screws things up since -O2 seems to override -fomit-frame-pointer.
>>>> My guess is that -O2 is from OPTIMIZATION == LOW, but not sure. How can
>>>> I get this -O2 flag removed which apparently gets added later?
> It was indeed an issue with OPTIMIZATION. A value of LOW is hard-coded
> in TestFilesCompilation. This patch fixes this by allowing one to
> override OPTIMIZATION per library via something like this:
>
> BUILD_HOTSPOT_JTREG_LIBRARIES_OPTIMIZATION_libNoFramePointer := HIGH
>
> diff --git a/make/common/TestFilesCompilation.gmk b/make/common/TestFilesCompilation.gmk
> --- a/make/common/TestFilesCompilation.gmk
> +++ b/make/common/TestFilesCompilation.gmk
> @@ -94,7 +94,7 @@
> CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
> LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \
> LIBS := $$($1_LIBS_$$(name)), \
> - OPTIMIZATION := LOW, \
> + OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)),$$($1_OPTIMIZATION_$$(name)),LOW), \
> COPY_DEBUG_SYMBOLS := false, \
> STRIP_SYMBOLS := false, \
> )) \
>
> Thanks,
> Severin
>
More information about the build-dev
mailing list