Don't play with CFLAGS and fix ld invocation
Brought to you by:
msw012
Hello,
I wanted to upstream a patch we are carrying for years on Gentoo to allow users to more easily get their CFLAGS/CXXFLAGS honoured. The patch also fixes LD invocation, that currently leads to this compilation error:
ld -pipe -o ../bin/gspiceui obj/*.o -L/usr/lib64 -pthread -lwx_gtk3u_core-3.2-gtk3 -lwx_baseu-3.2-gtk3 -lwx_gtk3u_html-3.2-gtk3
ld: unrecognized option '-pipe'
ld: use the --help option for usage information
make[1]: *** [Makefile:224: ../bin/gspiceui] Error 1
I have updated the patch for latest tree.
Thanks a lot
Hello Pacho,
Thanks for the patch. I've had a look at it and am happy to implement any of your suggestions that don't break the build system.
Some questions/comments :
1. When I set CXX and LD using ?= I get the same linker error you have reported. This Makefile
only builds successfully when gcc/g++ is specified.
2. As an experiment I tried the build using clang++ and it crashed and burned. The command line
arguments are specific to gcc/g++.
3. I've remove the -pipe option from non-debug builds but the -pthread option then becomes a
problem. This option is added by wx-config and is therefore required by wxWidgets.
4. Could you explain to me why it's a problem setting CXX, LD and CXXFLAGS. I'm a bit
confused. For me when they aren't set I get problems. I run Archlinux. What's different with
Gentoo do you think? Eg. does Gentoo use a different compiler?
Mike Waters
Hi!
For hardcoding g++ calls, we rely on been able to modify it to not break cross compilation
https://wiki.gentoo.org/wiki/Project:Tinderbox/Common_Issues_Helper#QA0014
In general we have no problems fixing them allowing to honor CXX variable as, for example:
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f2cd6dbe1d58fc112aad40afd52df90e7f74a6f2
But it is true that we pass CC and CXX variables to the desired values; Then, maybe a logic to fallback to CXX=g++ would be needed for the cases no CXX variable is set :/
What error is it showing when -pipe is not present? On Gentoo (with the patch) the compilation line ends up being:
x86_64-pc-linux-gnu-g++ -c -std=c++17 -fabi-version=14 -I/usr/lib64/wx/include/gtk3-unicode-3.2-gtk3 -I/usr/include/wx-3.2-gtk3 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -I. gnucap/NbkGnuCap.cpp -o obj/NbkGnuCap.o
And it compiles fine for us.
Not hard coding them is useful for properly cross compiling the package on different arches. Also, for LD, in the past it was also noticed when trying to compile using ld.gold (even if that is not an issue anymore). For the CXXFLAGS, it is useful to, for example, not force everybody to compile with debugging symbols (-g).
Thanks a lot
Hi Pacho,
After some head scratching I've come up with an idea that may satisfy everyone. What if I created a make variable (eg. GSPICEUI_GENTOO) that if set to 1 does all the things you want, if set to 0 the build system works as in the past. Ie. when envoking make for Gentoo the command line would be : make GSPICEUI_GENTOO=1.
Would this mechanism work for you?
Mike Waters
Sure, that would work fine. Maybe you can use a more general "GSPICEUI_CUSTOM_FLAGS" as maybe other distributions could benefit from that too. But, as you wish :)
Thanks a lot
OK. I'll make some mods. when I get chance and let you know so you can review them.
Hi Pacho,
I tried the GSPICEUI_GENTOO flag idea which worked but after some more head scratching I've come up with what I think is a better solution. This has been commited to the SVN. Hopefully this resolves all your problems.
Eg. : The following command specifies compiler and options :
make CXX=\[some compiler\] CXXFLAGS=\[some option\]Let me know how it goes.
Mike Waters