From: Michael Tremer Date: Sat, 7 Jan 2023 12:11:28 +0000 (+0000) Subject: macros: Construct LDFLAGS with more information and add -O1 X-Git-Tag: 0.9.29~404 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4026d3a011b986897c483035a9dd7c6d8e1eb670;p=pakfire.git macros: Construct LDFLAGS with more information and add -O1 Signed-off-by: Michael Tremer --- diff --git a/macros/build.macro b/macros/build.macro index dafc1d601..cfae9dc25 100644 --- a/macros/build.macro +++ b/macros/build.macro @@ -155,6 +155,8 @@ end # Pre-defined build scripts. build + configure = [ -x "%{CONFIGURE_SCRIPT}" ] && ./%{CONFIGURE_SCRIPT} %{configure_options} + # These variables are used if you have to add some targets # directly to the make command. make_build_targets = @@ -191,12 +193,11 @@ build end def build - if [ -e "%{CONFIGURE_SCRIPT}" ]; then - ./%{CONFIGURE_SCRIPT} \ - %{configure_options} + # Run configure + %{configure} - %{MACRO_FIX_LIBTOOL} - fi + # Remove any RPATH stuff from locally installed libtool + %{MACRO_FIX_LIBTOOL} # Run custom commands. %{configure_cmds} diff --git a/macros/cflags.macro b/macros/cflags.macro index e0f28117d..7fbe4ebb6 100644 --- a/macros/cflags.macro +++ b/macros/cflags.macro @@ -1,12 +1,12 @@ build # Export CFLAGS - export CFLAGS = # empty + export CFLAGS = # Export CXXFLAGS export CXXFLAGS = %{CFLAGS} # Export LDFLAGS - export LDFLAGS = -Wl,--as-needed -Wl,-z,relro -Wl,-z,now + export LDFLAGS = # Enable optimisation and compile in debugging information CFLAGS = -O2 -g @@ -48,6 +48,22 @@ build LTO_CFLAGS = -flto=auto -ffat-lto-objects CFLAGS += %{LTO_CFLAGS} + # Optimise linked binaries https://lwn.net/Articles/192624/ + LDFLAGS += -Wl,-O1 + + # Only link what we actually need + LDFLAGS += -Wl,--as-needed + + # Create an ELF "PT_GNU_RELRO" segment header in the object + LDFLAGS += -Wl,-z,relro + + # When generating an executable or shared library, mark it to tell the + # dynamic linker to resolve all symbols when the program is started, + # or when the shared library is linked to using dlopen, instead of + # deferring function call resolution to the point when the function is + # first called. + LDFLAGS += -Wl,-z,now + # Export default compilers export CC = gcc export CXX = g++ diff --git a/macros/cmake.macro b/macros/cmake.macro index 56d418edd..ed6ec354f 100644 --- a/macros/cmake.macro +++ b/macros/cmake.macro @@ -17,6 +17,7 @@ cmake = %{__cmake} \ -DCMAKE_INSTALL_DATAROOTDIR:PATH=%{datadir} \ %{__cmake_lib_suffix} \ -DBUILD_SHARED_LIBS:BOOL=ON \ + -DBUILD_STATIC_LIBS:BOOL=OFF \ \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{CFLAGS}" \