Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Unset macros to prevent 'redefined' errors during build #540

Closed
wants to merge 1 commit into from

Conversation

x4121
Copy link
Contributor

@x4121 x4121 commented Apr 23, 2017

In preparation to a (hopefully soon :) ) new release of newsbeuter, I tried to build Debian/Ubuntu binaries. Currently the build fails with

<command-line>:0:0: error: "LOCALEDIR" redefined [-Werror]
<command-line>:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
Makefile:112: recipe for target 'test/cache.o' failed
make[1]: *** [test/cache.o] Error 1

Unsetting the build macros before (re)setting them prevents this.

Tested on my private Launchpad PPA: https://launchpad.net/~x4121/+archive/ubuntu/ppa/+build/12464800 (which should behave similar/identical to the Debian build server that the release would be built on)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 36.726% when pulling 3370194 on x4121:pr/debuild_prepare into 5517dba on akrennmair:master.

1 similar comment
@coveralls
Copy link

coveralls commented Apr 23, 2017

Coverage Status

Coverage remained the same at 36.726% when pulling 3370194 on x4121:pr/debuild_prepare into 5517dba on akrennmair:master.

@Minoru
Copy link
Collaborator

Minoru commented Apr 23, 2017

This might be related to #431.

Unsetting macros is more of a workaround than a fix. Anyway, I'd like to know what causes this before deciding how to deal with it. What parameters are passed to make? What's the environment like (env)?

Debian package is maintained by @tsipinakis. Maybe he's got some information on this?

@x4121
Copy link
Contributor Author

x4121 commented Apr 23, 2017

Ah you are right.. I thought the problem was the macros being set during make and again during make test afterwards, because it only complained there..

All build steps look like (manually inserted line breaks for readability)

g++ -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2
-std=c++11 -ggdb -Iinclude -Istfl -Ifilter -I. -Irss -Werror -Wall -Wextra -Wunreachable-code
-DLOCALEDIR=\"/usr/share/locale\" -I/usr/include/libxml2  -I/usr/include/json-c  -I/usr/include/ncursesw 
-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2
-std=c++11 -ggdb -Iinclude -Istfl -Ifilter -I. -Irss -Werror -Wall -Wextra -Wunreachable-code
-DLOCALEDIR=\"/usr/share/locale\" -o src/configcontainer.o -c src/configcontainer.cpp

So yes, the macros get defined twice every step, but fails at

g++ -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2
-std=c++11 -ggdb -Iinclude -Istfl -Ifilter -I. -Irss -Werror -Wall -Wextra -Wunreachable-code
-DLOCALEDIR=\"/usr/local/share/locale\" -I/usr/include/libxml2  -I/usr/include/json-c 
-I/usr/include/ncursesw  -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security
-D_FORTIFY_SOURCE=2 -std=c++11 -ggdb -Iinclude -Istfl -Ifilter -I. -Irss -Werror -Wall -Wextra
-Wunreachable-code -DLOCALEDIR=\"/usr/share/locale\" -o test/cache.o -c test/cache.cpp
<command-line>:0:0: error: "LOCALEDIR" redefined [-Werror]
<command-line>:0:0: note: this is the location of the previous definition

@tsipinakis
Copy link
Contributor

tsipinakis commented Apr 24, 2017

I was in the middle of dumping a wall of text with all the variables that are set during the build process but I figured it out in the meantime. It's the same issue as #431.

If config.mk doesn't exist, config.sh is called by make which adds CXXFLAGS+=$CXXFLAGS to config.mk which is intended to append user-defined overrides to the flags, but make by default does not export its own variables unless they have been already set, in which case, it updates the values with whatever modifications happened within the makefile.

So if CXXFLAGS is not set, it's not exported so config.mk does not contain an extra copy of the flags and the bug does not happen. But if it is, it is updated with all the extra flags added inside the makefile, which results in 2 copies of CXXFLAGS, one from the makefile and one from the config.mk inclusion.

@Minoru
Copy link
Collaborator

Minoru commented Apr 24, 2017

@x4121, notice how the first command has two LOCALEDIR definitions with equal values, but the second has two definitions with different values. I wonder what's going on there. It looks like make test is called with a slightly different set of parameters than make. Can you look further into the script to see what might cause this?

@tsipinakis, thanks a lot for figuring this out! Let's move to #431 though.

@x4121
Copy link
Contributor Author

x4121 commented Apr 24, 2017

Totally missed the "local" in the second definition...
Will try to have a deeper look into it on the weekend :)

@Minoru
Copy link
Collaborator

Minoru commented Jun 13, 2017

Hi,

I'm going to close this because I'm not going to merge this changes, but if you find anything while looking for that second "LOCALEDIR" definition, please open an issue.

@Minoru Minoru closed this Jun 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants