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

cmake: add only non-system link paths to rpath (fixes #2849) #2850

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

robert-scheck
Copy link
Collaborator

This patch, even while maybe imperfect from CMake perspective, ensures that only non-system directories used for linking are added to RPATH. Fedora's /usr/lib/rpm/check-rpaths claims unnecessary standard RPATHs (e.g. /usr/lib).

While such RPATHs might be treated as a minor issue, they are still introducing redundant searchpaths without providing a benefit. They can also cause errors in multilib environments (e.g. /usr/lib instead of /usr/lib64on 64 bit Fedora systems).

@robert-scheck
Copy link
Collaborator Author

robert-scheck commented Dec 28, 2023

@larsimmisch and @bacterik, do you see any chance to test this pull request on macOS?

@sreimers
Copy link
Member

Maybe we should set rpath only on macOS and iOS?

if(APPLE)

@robert-scheck
Copy link
Collaborator Author

robert-scheck commented Dec 28, 2023

Maybe we should set rpath only on macOS and iOS?

Personally, I wouldn't do this, because Linux users might want to install baresip on non-default paths for whatever reasons.

Example: Baresip under /opt/baresip instead of Filesystem Hierarchy Standard (FHS).

@alfredh
Copy link
Collaborator

alfredh commented Dec 28, 2023

tested OK on macOS 12.7:

Alfreds-MBP-M1:baresip alfredh$ patch -p1 < 2850.diff 
patching file CMakeLists.txt
Alfreds-MBP-M1:baresip alfredh$ cmake .
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found RE: /usr/local/lib/libre.dylib  
-- Looking for backtrace
-- Looking for backtrace - found
-- backtrace facility detected in default set of libraries
-- Found Backtrace: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include  
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found ZLIB: /opt/local/lib/libz.dylib (found version "1.3.#define ZLIB_VERSION "1.3"") 
-- Found OpenSSL: /opt/local/libexec/openssl3/lib/libcrypto.dylib (found suitable version "3.2.0", minimum required is "1.1.1")  
-- Setting build type to 'Debug' as none was specified.
-- Looking for arc4random
-- Looking for arc4random - found
-- Looking for syslog.h
-- Looking for syslog.h - found
-- Looking for getopt.h
-- Looking for getopt.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for res_ninit
-- Looking for res_ninit - found
-- Looking for thrd_create
-- Looking for thrd_create - not found
-- Looking for threads.h
-- Looking for threads.h - not found
-- Looking for accept4
-- Looking for accept4 - not found
-- Looking for epoll_create
-- Looking for epoll_create - not found
-- Looking for kqueue
-- Looking for kqueue - found
-- Looking for sys/prctl.h
-- Looking for sys/prctl.h - not found
-- Performing Test atomic_test
-- Performing Test atomic_test - Success
-- Checking for one of the modules 'fdk-aac'
-- Could NOT find AAC (missing: AAC_LIBRARY AAC_INCLUDE_DIR) 
-- Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR) 
-- Found AMR: TRUE  
-- Found PkgConfig: /opt/local/bin/pkg-config (found version "0.29.2") 
-- Checking for one of the modules 'aptx'
-- Could NOT find APTX (missing: APTX_LIBRARY APTX_INCLUDE_DIR) 
-- Found AOM: /opt/local/lib/libaom.dylib (found version "3.8.0") 
-- Checking for one of the modules 'codec2'
-- Could NOT find CODEC2 (missing: CODEC2_LIBRARY CODEC2_INCLUDE_DIR) 
-- Could NOT find DIRECTFB (missing: DIRECTFB_LIBRARIES DIRECTFB_INCLUDE_DIR) 
-- Found FFMPEG: /opt/homebrew/bin/../lib/libavcodec.dylib (found version "#define LIBAVCODEC_VERSION_MINOR  31;#define LIBAVCODEC_VERSION_MICRO 102.31.102") found components: avcodec avfilter avformat swscale swresample avdevice avutil 
-- Checking for one of the modules 'g7221'
-- Could NOT find G7221 (missing: G7221_LIBRARY G7221_INCLUDE_DIR) 
-- Checking for module 'gio-unix-2.0'
--   Found gio-unix-2.0, version 2.78.0
-- Found GIO: /opt/local/lib/libglib-2.0.dylib  
-- Could NOT find GST (missing: GST_FOUND) 
-- Checking for module 'gtk+-3.0'
--   No package 'gtk+-3.0' found
-- Could NOT find GTK3 (missing: GTK3_LIBRARIES GTK3_CFLAGS GTK3_CFLAGS_OTHER) 
-- Could NOT find GZRTP (missing: GZRTP_LIBRARY GZRTP_INCLUDE_DIR) 
-- Checking for one of the modules 'jack'
-- Could NOT find JACK (missing: JACK_LIBRARY JACK_INCLUDE_DIR) 
-- Could NOT find MOSQUITTO (missing: MOSQUITTO_LIBRARY MOSQUITTO_INCLUDE_DIR) 
-- libmosquitto include dir: MOSQUITTO_INCLUDE_DIR-NOTFOUND
-- libmosquitto: MOSQUITTO_LIBRARY-NOTFOUND
-- Checking for one of the modules 'twolame'
-- Checking for one of the modules 'mpg123'
-- Checking for one of the modules 'speexdsp'
-- Could NOT find MPA (missing: MPA_LIBRARIES MPA_INCLUDE_DIRS) 
-- Could NOT find OPENSLES (missing: OPENSLES_LIBRARY OPENSLES_INCLUDE_DIR) 
-- Checking for one of the modules 'opus'
-- Found OPUS: /opt/local/lib/libopus.dylib  
-- Found PNG: /opt/local/lib/libpng.dylib  
-- Checking for one of the modules 'portaudio'
-- Found PORTAUDIO: /opt/homebrew/lib/libportaudio.dylib  
-- Checking for one of the modules 'pulse'
-- Could NOT find PULSE (missing: PULSE_LIBRARY PULSE_INCLUDE_DIR) 
-- Checking for one of the modules 'libpipewire-0.3'
-- Could NOT find PIPEWIRE (missing: PIPEWIRE_INCLUDE_DIRS PIPEWIRE_LIBRARIES) 
-- Checking for one of the modules 'sdl2'
-- Found SDL: /opt/local/lib/libSDL2.dylib  
-- Checking for module 'sndfile'
--   No package 'sndfile' found
-- Found SNDFILE: /opt/homebrew/include  
-- Found SPANDSP: /opt/homebrew/lib/libspandsp.dylib  
-- Checking for module 'libv4l2'
--   No package 'libv4l2' found
-- Could NOT find V4L2 (missing: V4L2_LIBRARY V4L2_INCLUDE_DIR) 
-- Found VPX: /opt/local/lib/libvpx.dylib  
-- Could NOT find WEBRTC_AEC (missing: WEBRTC_AEC_LIBRARY WEBRTC_AEC_INCLUDE_DIR) 
-- Could NOT find WEBRTC_AECM (missing: WEBRTC_AECM_LIBRARY WEBRTC_AECM_INCLUDE_DIR) 
-- Found X11: /opt/local/include   
-- Looking for XOpenDisplay in /opt/local/lib/libX11.dylib;/opt/local/lib/libXext.dylib
-- Looking for XOpenDisplay in /opt/local/lib/libX11.dylib;/opt/local/lib/libXext.dylib - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/alfredh/tmp/baresip
Alfreds-MBP-M1:baresip alfredh$ make
[  0%] Building C object CMakeFiles/baresip.dir/src/account.c.o
[  0%] Building C object CMakeFiles/baresip.dir/src/aucodec.c.o
[  1%] Building C object CMakeFiles/baresip.dir/src/audio.c.o
[  1%] Building C object CMakeFiles/baresip.dir/src/aufilt.c.o
[  1%] Building C object CMakeFiles/baresip.dir/src/auplay.c.o
[  2%] Building C object CMakeFiles/baresip.dir/src/aureceiver.c.o
[  2%] Building C object CMakeFiles/baresip.dir/src/ausrc.c.o
...

@alfredh alfredh merged commit 7ef2eab into baresip:main Dec 28, 2023
16 checks passed
@robert-scheck
Copy link
Collaborator Author

tested OK on macOS 12.7:

Given you only showed build-time output…the (breaking) CMake code was added for a reported run-time issue on macOS.

@larsimmisch
Copy link
Contributor

@robert-scheck Looks good to me.

I tested this on MacOS 14.2.1 by running:

  • cmake -B build
  • cmake --build build
  • cmake --install build

And then running baresip from the path. baresip started up fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants