Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDFLAGS containing "-Wl,-z,pack-relative-relocs" breaks build #24919

Open
1 of 7 tasks
graysky2 opened this issue Mar 30, 2024 · 7 comments
Open
1 of 7 tasks

LDFLAGS containing "-Wl,-z,pack-relative-relocs" breaks build #24919

graysky2 opened this issue Mar 30, 2024 · 7 comments
Labels
Triage: Confirmed issue has been reproduced by a team member

Comments

@graysky2
Copy link
Contributor

graysky2 commented Mar 30, 2024

Bug report

Describe the bug

Here is a clear and concise description of what the problem is:

When building with LDFLAGS containing -Wl,-z,pack-relative-relocs, cmake fails to find Threads.

Expected Behavior

Here is a clear and concise description of what was expected to happen:

The build should work.

Actual Behavior

The build breaks:

...
-- Found PkgConfig: /usr/bin/pkg-config (found version "2.1.1")
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:166 (find_package)

Possible Fix

To Reproduce

Steps to reproduce the behavior:

  1. Use the following *FLAGS and try building

Note: these are currently Arch Linux's distro default:

CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection \
        -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now \
         -Wl,-z,pack-relative-relocs"

Debuglog

The debuglog can be found here:

Screenshots

Here are some links or screenshots to help explain the problem:

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

Your Environment

Used Operating system:

  • Android

  • iOS

  • tvOS

  • Linux

  • macOS

  • Windows

  • Windows UWP

  • Operating system version/name: Arch Linux

  • Kodi version: master

note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

@xbmc-gh-bot xbmc-gh-bot bot added the Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it label Mar 30, 2024
@ilikenwf
Copy link

+1, currently am using sed to remove the offending flag but it would be nice not to have to do this.

@graysky2
Copy link
Contributor Author

graysky2 commented Mar 30, 2024

You don't need to call sed:

% LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs"
% echo ${LDFLAGS}
-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs
% echo ${LDFLAGS/-Wl,-z,pack-relative-relocs/}
-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now

@ilikenwf
Copy link

That works too - I guess sed is a little heavy. I did not realize echo could do that...and I've been using Linux for like 20 years.

@graysky2
Copy link
Contributor Author

@neo1973
Copy link
Member

neo1973 commented Mar 30, 2024

Not sure what's going on, but if you build with -DENABLE_MOLD=ON it works. And for the sake of build times I would recommend that anyway 😉

CMake command
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS" LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs" CC=gcc CXX=g++ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib -DENABLE_AIRTUNES=ON -DENABLE_ALSA=ON -DENABLE_AVAHI=ON -DENABLE_BLURAY=ON -DENABLE_CEC=ON -DENABLE_DBUS=ON -DENABLE_DVDCSS=ON -DENABLE_EGL=ON -DENABLE_EVENTCLIENTS=ON -DENABLE_MICROHTTPD=ON -DENABLE_MYSQLCLIENT=ON -DENABLE_NFS=ON -DENABLE_OPTICAL=ON -DENABLE_PULSEAUDIO=ON -DENABLE_SMBCLIENT=ON -DENABLE_UDEV=ON -DENABLE_UPNP=ON -DENABLE_VAAPI=ON -DENABLE_XSLT=ON -DENABLE_INTERNAL_FFMPEG=ON -DENABLE_MOLD=ON -DCORE_PLATFORM_NAME='wayland;gbm' -DAPP_RENDER_SYSTEM=gl -G Ninja ../xbmc/
Output
-- The CXX compiler identification is GNU 13.2.1
-- The C compiler identification is GNU 13.2.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/gcc
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Mirror download location: http://mirrors.kodi.tv
-- Source directory: /home/mark/Coding/Repos/kodi-git/xbmc
-- Build directory: /home/mark/Coding/Repos/kodi-git/build_tmp
-- Generator: Single-configuration: Release (Ninja)
-- CMake Version: 3.29.0
-- System type: Linux
-- Found MOLD: /usr/bin/mold
-- Linker: mold
-- Host architecture is little-endian
-- Core system type: linux
-- Platform: wayland;gbm
-- CPU: x86_64, ARCH: x86_64-linux
-- Cross-Compiling: FALSE
-- Execute build artefacts on host: 
-- Depends based build: 
-- statx is available
CMake Warning (dev) at cmake/modules/FindSSE.cmake:7 (exec_program):
  Policy CMP0153 is not set: The exec_program command should not be called.
  Run "cmake --help-policy CMP0153" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Use execute_process() instead.
Call Stack (most recent call first):
  cmake/scripts/common/ArchSetup.cmake:132 (find_package)
  CMakeLists.txt:60 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Checking to see if CXX compiler accepts flag -msse
-- Checking to see if CXX compiler accepts flag -msse - yes
-- Checking to see if CXX compiler accepts flag -msse2
-- Checking to see if CXX compiler accepts flag -msse2 - yes
-- Checking to see if CXX compiler accepts flag -msse3
-- Checking to see if CXX compiler accepts flag -msse3 - yes
-- Checking to see if CXX compiler accepts flag -mssse3
-- Checking to see if CXX compiler accepts flag -mssse3 - yes
-- Checking to see if CXX compiler accepts flag -msse4.1
-- Checking to see if CXX compiler accepts flag -msse4.1 - yes
-- Checking to see if CXX compiler accepts flag -msse4.2
-- Checking to see if CXX compiler accepts flag -msse4.2 - yes
-- Checking to see if CXX compiler accepts flag -mavx
-- Checking to see if CXX compiler accepts flag -mavx - yes
-- Checking to see if CXX compiler accepts flag -mavx2
-- Checking to see if CXX compiler accepts flag -mavx2 - yes
-- Found SSE: 1
-- Found SSE2: 1
-- Found SSE3: 1
-- Found SSSE3: 1
-- Found SSE4_1: 1
-- Found SSE4_2: 1
-- Found AVX: 1
-- Found AVX2: 1
-- Found Git: /usr/bin/git (found version "2.44.0")
-- Found PkgConfig: /usr/bin/pkg-config (found version "2.1.1")
-- Found CCache: /usr/bin/ccache (found version "4.9.1")
-- Found ClangFormat: /usr/bin/clang-format (found version "17.0.6")
-- Found FlatC Compiler: /bin/flatc (found version "24.3.7")
-- Found JsonSchemaBuilder: /home/mark/Coding/Repos/kodi-git/build_tmp/build/bin/JsonSchemaBuilder
-- Found Lzo2: /usr/lib/liblzo2.so
-- Found ZLIB: /usr/lib/libz.so (found version "1.3.1")
-- Found PNG: /usr/lib/libpng.so (found version "1.6.43")
-- Found GIF: /usr/lib/libgif.so (found version "5.2.2")
-- Found JPEG: /usr/lib/libjpeg.so (found version "80")
-- Building internal TexturePacker
-- Shipping internal TexturePacker
-- Internal TexturePacker will be executed during build
-- Found Alsa: /usr/lib/libasound.so (found suitable version "1.2.11", minimum required is "1.0.27")
-- Found Avahi: /usr/lib/libavahi-client.so (found version "0.8")
-- Found Bluetooth: /usr/lib/libbluetooth.so
-- Found Bluray: /usr/lib/libbluray.so (found suitable version "1.3.4", minimum required is "0.9.3")
-- Found CAP: /usr/lib/libcap.so (found version "2.69")
-- Could NOT find libcec (missing: libcec_DIR)
-- Found CEC: /usr/lib/libcec.so (found suitable version "6.0.2", minimum required is "4.0.0")
-- Found Dav1d: /usr/lib/libdav1d.so (found version "1.4.1")
-- Found DBus: /usr/lib/libdbus-1.so (found version "1.14.10")
-- Found Cdio: /usr/lib/libcdio.so (found version "2.1.0")
-- Found Iso9660pp: /usr/lib/libiso9660++.so (found suitable version "2.1.0", minimum required is "2.1.0")
-- Found LCMS2: /usr/lib/liblcms2.so (found suitable version "2.16", minimum required is "2.10")
-- Found LircClient: /usr/lib/liblirc_client.so
-- Could NOT find MDNS (missing: MDNS_LIBRARY) 
-- Found MicroHttpd: /usr/lib/libmicrohttpd.so (found suitable version "1.0.1", minimum required is "0.9.40")
-- Found NFS: /usr/lib/libnfs.so (found suitable version "5.0.3", minimum required is "3.0.0")
-- Found Pipewire: /usr/lib/libpipewire-0.3.so (found suitable version "1.0.4", minimum required is "0.3.50")
-- Found Plist: /usr/lib/libplist-2.0.so (found version "2.4.0")
-- Found PulseAudio: /usr/lib/libpulse.so (found suitable version "17.0", minimum required is "11.0.0")
-- Found Python3: /usr/include/python3.11 (found version "3.11.8") found components: Development Development.Module Development.Embed
-- Found SmbClient: /usr/lib/libsmbclient.so (found version "0.8.0")
-- Found Sndio: /usr/lib/libsndio.so
-- Found UDEV: /usr/lib/libudev.so (found version "255")
-- Found udfread: /home/mark/Coding/Repos/kodi-git/build_tmp/build/lib/libudfread.a (version: "1.1.2")
-- Found LibXml2: /usr/lib/libxml2.so (found version "2.12.6")
-- Found XSLT: /usr/lib/libxslt.so (found version "1.1.39")
-- Found VAAPI: /usr/lib/libva.so (found suitable version "1.21.0", minimum required is "0.39.0")
-- Found ASS: /usr/lib/libass.so (found suitable version "0.17.1", minimum required is "0.15.0")
-- Found Patch: /usr/bin/patch (found version "2.7.6")
-- Found CrossGUID: optimized;/home/mark/Coding/Repos/kodi-git/build_tmp/build/lib/libcrossguid.a;debug;/home/mark/Coding/Repos/kodi-git/build_tmp/build/lib/libcrossguid-dgb.a (found version "ca1bf4b810e2d188d04cb6286f957008ee1b7681")
-- Found UUID: /usr/lib/libuuid.so (found version "2.40.0")
-- Found Curl: /usr/lib/libcurl.so (found version "8.7.1")
-- Found FlatBuffers: /usr/include/
-- Found Fmt: /usr/lib/libfmt.so.10.2.0 (found version "10.2.0")
-- Found FreeType: /usr/lib/libfreetype.so (found version "26.1.20")
-- Found FriBidi: /usr/lib/libfribidi.so (found version "1.0.13")
-- Found Fstrcmp: /usr/lib/libfstrcmp.so (found version "0.7.D001")
-- Found HarfBuzz: /usr/lib/libharfbuzz.so (found version "8.4.0")
-- Found Iconv: /usr/lib/libc.so
-- Found KissFFT: /home/mark/Coding/Repos/kodi-git/xbmc/xbmc/contrib
-- Found LibDvdCSS: /home/mark/Coding/Repos/kodi-git/build_tmp/build/lib/libdvdcss.a (found version "1.4.3-Next-Nexus-Alpha2-2")
-- Found LibDvdRead: /home/mark/Coding/Repos/kodi-git/build_tmp/build/lib/libdvdread.a (found version "6.1.3-Next-Nexus-Alpha2-2")
-- Found LibDvdNav: /home/mark/Coding/Repos/kodi-git/build_tmp/build/lib/libdvdnav.a (found version "6.1.1-Next-Nexus-Alpha2-2")
-- Found OpenSSL: /usr/lib/libcrypto.so (found suitable version "3.2.1", minimum required is "1.1.0")
-- Found PCRE: /usr/lib/libpcre.so
-- RapidJSON found. Headers: /usr/include
-- Found RapidJSON: /usr/include (found suitable version "1.1.0", minimum required is "1.0.2")
-- Found Spdlog: /usr/lib/libspdlog.so (found version "1.13.0")
-- Found Sqlite3: /usr/lib/libsqlite3.so (found version "3.45.2")
-- Found TagLib: /usr/lib/libtag.so (found suitable version "2.0", minimum required is "1.9.0")
-- Found TinyXML: /usr/lib/libtinyxml.so (found version "2.6.2")
-- Found TinyXML2: /usr/lib/libtinyxml2.so.10.0.0 (found version "10.0.0")
-- Checking for module 'wayland-protocols'
--   Found wayland-protocols, version 1.34
-- Found WaylandProtocols: 1 (found suitable version "1.34", minimum required is "1.7")
-- Found Waylandpp: /usr/include (Required is at least version "0.2.2")
-- Found LibDRM: /usr/lib/libdrm.so (found suitable version "2.4.120", minimum required is "2.4.95")
-- Found Xkbcommon: /usr/lib/libxkbcommon.so (found suitable version "1.7.0", minimum required is "0.4.1")
-- Found OpenGl: /usr/lib/libGL.so
-- Found EGL: /usr/lib/libEGL.so (found version "1.5")
-- Found GBM: /usr/lib/libgbm.so (found version "24.0.3-arch1.2")
-- Found LibInput: /usr/lib/libinput.so (found version "1.25.0")
-- Found LibDisplayInfo: /usr/lib/libdisplay-info.so (found version "0.1.1")
-- Found MySqlClient: /usr/lib/libmysqlclient.so (found version "")
-- Found Shairplay: /usr/lib/libshairplay.so
-- Found Java: /usr/bin/java (found version "11.0.22") found components: Runtime
-- Found SWIG: /bin/swig (found version "4.1.1")
-- Found Gtest: /usr/lib/libgtest.so (found suitable version "1.14.0", minimum required is "1.10.0")
-- Found Doxygen: /usr/bin/doxygen (found version "1.10.0") found components: doxygen dot
-- Found PythonInterpreter: /bin/python3 (found version "3.11.8")
-- #---- CONFIGURATION ----#
-- Platforms: wayland gbm
-- App package: org.xbmc.kodi
-- -- PATH config --
-- Prefix: /usr
-- Libdir: /usr/lib
-- Bindir: /usr/bin
-- Includedir: /usr/include
-- Datarootdir: /usr/share
-- Datadir: /usr/share
-- Docdir: /usr/share/doc/kodi
-- CCACHE enabled: Yes
-- CLANGFORMAT enabled: Yes
-- CLANGTIDY enabled: No
-- CPPCHECK enabled: No
-- INCLUDEWHATYOUUSE enabled: No
-- ALSA enabled: Yes
-- AVAHI enabled: Yes
-- BLUETOOTH enabled: Yes
-- BLURAY enabled: Yes
-- CAP enabled: Yes
-- CEC enabled: Yes
-- DAV1D enabled: Yes
-- DBUS enabled: Yes
-- ISO9660PP enabled: Yes
-- LCMS2 enabled: Yes
-- LIRCCLIENT enabled: Yes
-- MDNS enabled: No
-- MICROHTTPD enabled: Yes
-- NFS enabled: Yes
-- PIPEWIRE enabled: Yes
-- PLIST enabled: Yes
-- PULSEAUDIO enabled: Yes
-- PYTHON enabled: Yes
-- SMBCLIENT enabled: Yes
-- SNDIO enabled: Yes
-- UDEV enabled: Yes
-- UDFREAD enabled: No
-- XSLT enabled: Yes
-- VAAPI enabled: Yes
-- VAAPI enabled: Yes
-- MARIADBCLIENT enabled: No
-- MYSQLCLIENT enabled: Yes
-- Configuring done (17.7s)
-- Generating done (0.8s)
-- Build files have been written to: /home/mark/Coding/Repos/kodi-git/build_tmp

@graysky2
Copy link
Contributor Author

Thanks for the suggestion, will give it a try... what does -DENABLE_MOLD=ON do exactly?

@neo1973
Copy link
Member

neo1973 commented Mar 31, 2024

With this the Mold linker is used. Requires Mold to be installed though. So far I don't understand why it makes a difference but it somehow works?

@neo1973 neo1973 added Triage: Confirmed issue has been reproduced by a team member and removed Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it labels Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage: Confirmed issue has been reproduced by a team member
Projects
None yet
Development

No branches or pull requests

3 participants