]> git.ipfire.org Git - pakfire.git/commitdiff
macros: Construct LDFLAGS with more information and add -O1
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 7 Jan 2023 12:11:28 +0000 (12:11 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 7 Jan 2023 12:11:28 +0000 (12:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
macros/build.macro
macros/cflags.macro
macros/cmake.macro

index dafc1d601efa5c1c3e0793bb7b98771ae1c56ee9..cfae9dc25d06694baf506fbc846cf5229f435c2e 100644 (file)
@@ -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}
index e0f28117d380016353829308a69ebec43d09f21f..7fbe4ebb6a15b5c83ca4454c94b1748b0012e556 100644 (file)
@@ -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++
index 56d418edd54afbf9aa48061f9f9237969d803b9f..ed6ec354feb34162177126c85b944798d5515001 100644 (file)
@@ -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}" \