Menu

#30 Don't play with CFLAGS and fix ld invocation

v1.2
open
nobody
None
5
2024-07-22
2024-06-21
Pacho Ramos
No

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

1 Attachments

Discussion

  • Mike W.

    Mike W. - 2024-07-22

    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

     
    • Pacho Ramos

      Pacho Ramos - 2024-07-22

      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

       

Log in to post a comment.