| Summary: | CMake build fails to link a shared library on OpenBSD | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Vitaly Novichkov <admin> |
| Component: | build | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | brad, sezeroz |
| Version: | 2.0.12 | ||
| Hardware: | x86_64 | ||
| OS: | OpenBSD | ||
| Attachments: |
A build output
My CMake cache to inspect |
||
|
Description
Vitaly Novichkov
2020-06-05 08:40:34 UTC
It looks like somehow it's not linking with the standard C library... ? Yes, libc didn't link, was that connected to the "enable libc" flag? Just now I reminded that I had a similar mess when I tried to build one of my projects on Windows with MSVC (in most I use MinGW, MSVC very rare), or something not that... don't remind accurate... Yes, did you disable the "enable libc" flag? We don't expect that on UNIX, and that may not work correctly. No, in my build I didn't set any libc flags at cmake build and I built it with most commmon case. I had to pass these cmake flags only: https://github.com/WohlSoft/AudioCodecs/blob/master/download_sdl2_hg.cmake#L57 No failure other platforms than OpenBSD. Didn't tested FreeBSD and NetBSD yet. Created attachment 4372 [details]
A build output
For a test, I did the pure test:
- cloned the SDL hg repo
ran next:
```
sudo pkg_add ninja cmake
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
ninja
```
and then I got this failure.
Created attachment 4373 [details]
My CMake cache to inspect
I see that libc flag is enabled, but the shared library fails to be built on a link step because of libc...
Looks like the CMake infrastructure has a bug. The autoconf build knows to not utilize --no-undefined on OpenBSD since that is not usable with shared libs. I was wondering why we had not seen this with our official packages but I haven't moved to CMake yet. AC_MSG_CHECKING(for linker option --no-undefined)
have_no_undefined=no
case "$host" in
dnl Skip this on platforms where it is just simply busted.
*-*-openbsd*)
;;
*)
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,--no-undefined"
AC_TRY_LINK([
],[
],[
have_no_undefined=yes
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--no-undefined"
])
LDFLAGS="$save_LDFLAGS"
;;
esac
AC_MSG_RESULT($have_no_undefined)
if(APPLE)
list(APPEND EXTRA_LDFLAGS "-Wl,-undefined,error")
list(APPEND EXTRA_LDFLAGS "-Wl,-compatibility_version,${DYLIB_COMPATIBILITY_VERSION}")
list(APPEND EXTRA_LDFLAGS "-Wl,-current_version,${DYLIB_CURRENT_VERSION}")
else()
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(HAVE_NO_UNDEFINED)
list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
endif()
endif()
Not knowing much about CMake... I would think you could change the "else()" to something like "elseif (NOT OPENBSD)"
(In reply to Brad Smith from comment #8) > Not knowing much about CMake... I would think you could change the "else()" > to something like "elseif (NOT OPENBSD)" That change is now https://hg.libsdl.org/SDL/rev/c4ef403dbc59 Closing as fixed. |