Old build problem: unpack200 failure when setting OTHER_CXXFLAGS in environment (original) (raw)

Kelly O'Hair kelly.ohair at oracle.com
Mon Mar 12 23:03:01 UTC 2012


Just seems like a very poorly written Makefile to me.

Where is the actual webrev or patch, I could not see it.

-kto

On Mar 11, 2012, at 9:48 PM, David Holmes wrote:

This is a blast from the past:

http://mail.openjdk.java.net/pipermail/build-dev/2007-May/000026.html but the above issue and patch seem to have been ignored. I just ran into this myself. /export/users/dh198349/jdk8/builds/b01/se8-linux-i586-ea/tmp/sun/com.sun.java.util.jar.pack/unpack-cmd/obj/main.o: In function unpacker::run(int, char**)':_ _main.cpp:(.text+0xe0b): undefined reference to gunzip::init(unpacker*)' main.cpp:(.text+0xe1d): undefined reference to gunzip::start(int)'_ _collect2: ld returned 1 exit status_ _make[7]: *** [/export/users/dh198349/jdk8/builds/b01/se8-linux-i586-ea/bin/unpack200] Error 1_ _The basic issue is one of recursive makes, with conditionally set variables that might also be set externally in the environment. Here's an example Makefile:_ _build: unpack_ _ifdef STANDALONE_ _FLAGS+=-XstandAlone_ _else_ _FLAGS+=-Xcombined_ _endif_ _unpack:_ _@make STANDALONE=true unpackexe_ _build:_ _@echo build FLAGS = $(FLAGS)_ _unpackexe:_ _@echo unpackexe FLAGS = $(FLAGS)_ _.phony: build unpack unpackexe_ _---_ _Here's a normal run:_ _> make build_ _make[1]: Entering directory /scratch/dh198349' unpackexe FLAGS = -XstandAlone make[1]: Leaving directory /scratch/dh198349'_ _build FLAGS = -Xcombined_ _which is what we would expect. But if you now give FLAGS an initial external value:_ _> FLAGS=external make build_ _make[1]: Entering directory /scratch/dh198349' unpackexe FLAGS = external -Xcombined -XstandAlone make[1]: Leaving directory `/scratch/dh198349' build FLAGS = external -Xcombined Yikes! Now unpackexe sees both the STANDALONE and non-STANDALONE value of FLAGS. This is because make re-exports any variable that came in from the environment. So when the top-level make is called, FLAGS==external, and to that the Makefile adds -Xcombined, so the sub-make effectively becomes: make FLAGS="external -Xcombined" STANDALONE=true unpackexe Here's one way to fix this: # save original incoming FLGS ORIGFLAGS := $(FLAGS) # hide any locally modified value of FLAGS unexport FLAGS build: unpack ifdef STANDALONE # override to allow sub-make to add to FLAGS override FLAGS+=-XstandAlone else FLAGS+=-Xcombined endif unpack: # Send in ORIGFLAGS as FLAGS @make FLAGS=$(ORIGFLAGS) STANDALONE=true unpackexe build: @echo build FLAGS = $(FLAGS) unpackexe: @echo unpackexe FLAGS = $(FLAGS) .phony: build unpack unpackexe ---- Or as per the original Patch, use a different variable in the Makefile to that set in the environment. David -----



More information about the build-dev mailing list