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 Build system issue using CheckFunctionExists #3467

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

CMake Build system issue using CheckFunctionExists #3467

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.1
Reported for operating system, platform: All, All

Comments on the original bug report:

On 2019-12-05 01:34:34 +0000, Manuel Sabogal wrote:

Created attachment 4089
CMake Patch for CheckFunctionExists issue

As part of the build system task to check certain symbols exist on the platform, SDL uses on the CMake build system the function check_function_exists from the CMake module https://cmake.org/cmake/help/latest/module/CheckFunctionExists.html.

The issue I'm currently having is specifically with iOS, when trying to build SDL on iOS the compiler is complaining that it cannot use certain functions like fseeko64 or fopen64, all the 64bit functions on MacOS/iOS are not available and their counterpart (without the 64) should be used, see: https://stackoverflow.com/a/4003512.

Even if they are not available in the system headers check_function_exists still reports that those functions exist can be used, which causes the problem in platforms like MacOS or iOS.

To solve this problem CMake on the CheckFunctionExists module documentation recommends using the module CheckSymbolExists with the function check_symbol_exists.

I attached a patch that should fix the issue.

On 2020-04-13 19:22:45 +0000, Ryan C. Gordon wrote:

This patch is now https://hg.libsdl.org/SDL/rev/a747072c5ae5, thanks!

--ryan.

On 2020-10-11 21:58:46 +0000, Ozkan Sezer wrote:

With this change, multiple libc symbols -- like malloc, strcmp,
memset, etc... -- can not be found for MinGW, because cmake's
check procedure includes non-existing dlfcn.h. Removing dlfcn.h
from the STDC_HEADER_NAMES makes it find the libc symbols again.

On 2020-10-11 22:18:47 +0000, Ozkan Sezer wrote:

This happens with a cross-environment with cmake-3.11.2 on fedora-27,
and with cmake-3.96 on centos-6.10.

My toolchain file I use on centos-6.10 is like this:

SET(CMAKE_SYSTEM_NAME Windows)

SET(CMAKE_C_COMPILER /opt/cross_win64/bin/x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER /opt/cross_win64/bin/x86_64-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER /opt/cross_win64/bin/x86_64-w64-mingw32-windres)

where is the target environment

SET(CMAKE_FIND_ROOT_PATH /opt/cross_win64 /opt/cross_win64/x86_64-w64-mingw32)

adjust the default behaviour of the FIND_XXX() commands:

search headers and libraries in the target environment, search

programs in the host environment

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

The console output is like this:

$ cmake -DCMAKE_TOOLCHAIN_FILE=Toolchain-MinGW64.cmake ..
-- The C compiler identification is GNU 4.5.4
-- The CXX compiler identification is GNU 4.5.4
-- Check for working C compiler: /opt/cross_win64/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /opt/cross_win64/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /opt/cross_win64/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /opt/cross_win64/bin/x86_64-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.23")
-- Performing Test HAVE_GCC_WALL
-- Performing Test HAVE_GCC_WALL - Success
-- Performing Test HAVE_GCC_NO_STRICT_ALIASING
-- Performing Test HAVE_GCC_NO_STRICT_ALIASING - Success
-- Performing Test HAVE_GCC_WDECLARATION_AFTER_STATEMENT
-- Performing Test HAVE_GCC_WDECLARATION_AFTER_STATEMENT - Success
-- Performing Test HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT
-- Performing Test HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT - Success
-- Performing Test HAVE_GCC_ATOMICS
-- Performing Test HAVE_GCC_ATOMICS - Success
-- Performing Test HAVE_GCC_PREFERRED_STACK_BOUNDARY
-- Performing Test HAVE_GCC_PREFERRED_STACK_BOUNDARY - Failed
-- Performing Test HAVE_GCC_FVISIBILITY
-- Performing Test HAVE_GCC_FVISIBILITY - Failed
-- Performing Test HAVE_GCC_WSHADOW
-- Performing Test HAVE_GCC_WSHADOW - Success
-- Performing Test HAVE_NO_UNDEFINED
-- Performing Test HAVE_NO_UNDEFINED - Success
-- Performing Test HAVE_MMX
-- Performing Test HAVE_MMX - Success
-- Performing Test HAVE_3DNOW
-- Performing Test HAVE_3DNOW - Success
-- Performing Test HAVE_SSE
-- Performing Test HAVE_SSE - Success
-- Performing Test HAVE_SSE2
-- Performing Test HAVE_SSE2 - Success
-- Performing Test HAVE_SSE3
-- Performing Test HAVE_SSE3 - Success
-- Looking for immintrin.h
-- Looking for immintrin.h - found
-- Performing Test HAVE_ALTIVEC_H_HDR
-- Performing Test HAVE_ALTIVEC_H_HDR - Failed
-- Performing Test HAVE_ALTIVEC
-- Performing Test HAVE_ALTIVEC - Failed
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdio.h
-- Looking for stdio.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Looking for stdarg.h
-- Looking for stdarg.h - found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for limits.h
-- Looking for limits.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for wchar.h
-- Looking for wchar.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for ctype.h
-- Looking for ctype.h - found
-- Looking for math.h
-- Looking for math.h - found
-- Looking for iconv.h
-- Looking for iconv.h - not found
-- Looking for signal.h
-- Looking for signal.h - found
-- Looking for libunwind.h
-- Looking for libunwind.h - not found
-- Looking for 10 include files dlfcn.h, ..., float.h
-- Looking for 10 include files dlfcn.h, ..., float.h - not found
-- Check size of size_t
-- Check size of size_t - done
-- Looking for M_PI
-- Looking for M_PI - found
-- Performing Test HAVE_MPROTECT
-- Performing Test HAVE_MPROTECT - Failed
-- Looking for strtod
-- Looking for strtod - not found
-- Looking for malloc
-- Looking for malloc - not found
-- Looking for calloc
-- Looking for calloc - not found
-- Looking for realloc
-- Looking for realloc - not found
-- Looking for free
-- Looking for free - not found
-- Looking for getenv
-- Looking for getenv - not found
-- Looking for setenv
-- Looking for setenv - not found
-- Looking for putenv
-- Looking for putenv - not found
-- Looking for unsetenv
-- Looking for unsetenv - not found
-- Looking for qsort
-- Looking for qsort - not found
-- Looking for abs
-- Looking for abs - not found
-- Looking for bcopy
-- Looking for bcopy - not found
-- Looking for memset
-- Looking for memset - not found
-- Looking for memcpy
-- Looking for memcpy - not found
-- Looking for memmove
-- Looking for memmove - not found
-- Looking for memcmp
-- Looking for memcmp - not found
-- Looking for strlen
-- Looking for strlen - not found
-- Looking for strlcpy
-- Looking for strlcpy - not found
-- Looking for strlcat
-- Looking for strlcat - not found
-- Looking for _strrev
-- Looking for _strrev - not found
-- Looking for _strupr
-- Looking for _strupr - not found
-- Looking for _strlwr
-- Looking for _strlwr - not found
-- Looking for strchr
-- Looking for strchr - not found
-- Looking for strrchr
-- Looking for strrchr - not found
-- Looking for strstr
-- Looking for strstr - not found
-- Looking for strtok_r
-- Looking for strtok_r - not found
-- Looking for itoa
-- Looking for itoa - not found
-- Looking for _ltoa
-- Looking for _ltoa - not found
-- Looking for _uitoa
-- Looking for _uitoa - not found
-- Looking for _ultoa
-- Looking for _ultoa - not found
-- Looking for strtol
-- Looking for strtol - not found
-- Looking for strtoul
-- Looking for strtoul - not found
-- Looking for _i64toa
-- Looking for _i64toa - not found
-- Looking for _ui64toa
-- Looking for _ui64toa - not found
-- Looking for strtoll
-- Looking for strtoll - not found
-- Looking for strtoull
-- Looking for strtoull - not found
-- Looking for atoi
-- Looking for atoi - not found
-- Looking for atof
-- Looking for atof - not found
-- Looking for strcmp
-- Looking for strcmp - not found
-- Looking for strncmp
-- Looking for strncmp - not found
-- Looking for _stricmp
-- Looking for _stricmp - not found
-- Looking for strcasecmp
-- Looking for strcasecmp - not found
-- Looking for _strnicmp
-- Looking for _strnicmp - not found
-- Looking for strncasecmp
-- Looking for strncasecmp - not found
-- Looking for wcscmp
-- Looking for wcscmp - not found
-- Looking for wcsdup
-- Looking for wcsdup - not found
-- Looking for wcslcat
-- Looking for wcslcat - not found
-- Looking for wcslcpy
-- Looking for wcslcpy - not found
-- Looking for wcslen
-- Looking for wcslen - not found
-- Looking for wcsncmp
-- Looking for wcsncmp - not found
-- Looking for wcsstr
-- Looking for wcsstr - not found
-- Looking for sscanf
-- Looking for sscanf - not found
-- Looking for vsscanf
-- Looking for vsscanf - not found
-- Looking for vsnprintf
-- Looking for vsnprintf - not found
-- Looking for fopen64
-- Looking for fopen64 - not found
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for fseeko64
-- Looking for fseeko64 - not found
-- Looking for _Exit
-- Looking for _Exit - not found
-- Looking for sigaction
-- Looking for sigaction - not found
-- Looking for setjmp
-- Looking for setjmp - found
-- Looking for nanosleep
-- Looking for nanosleep - not found
-- Looking for sysconf
-- Looking for sysconf - not found
-- Looking for sysctlbyname
-- Looking for sysctlbyname - not found
-- Looking for getauxval
-- Looking for getauxval - not found
-- Looking for poll
-- Looking for poll - not found
-- Looking for pow in m
-- Looking for pow in m - found
-- Looking for atan
-- Looking for atan - found
-- Looking for atan2
-- Looking for atan2 - found
-- Looking for atanf
-- Looking for atanf - found
-- Looking for atan2f
-- Looking for atan2f - found
-- Looking for ceil
-- Looking for ceil - found
-- Looking for ceilf
-- Looking for ceilf - found
-- Looking for copysign
-- Looking for copysign - found
-- Looking for copysignf
-- Looking for copysignf - found
-- Looking for cos
-- Looking for cos - found
-- Looking for cosf
-- Looking for cosf - found
-- Looking for exp
-- Looking for exp - found
-- Looking for expf
-- Looking for expf - found
-- Looking for fabs
-- Looking for fabs - found
-- Looking for fabsf
-- Looking for fabsf - found
-- Looking for floor
-- Looking for floor - found
-- Looking for floorf
-- Looking for floorf - found
-- Looking for fmod
-- Looking for fmod - found
-- Looking for fmodf
-- Looking for fmodf - found
-- Looking for log
-- Looking for log - found
-- Looking for logf
-- Looking for logf - found
-- Looking for log10
-- Looking for log10 - found
-- Looking for log10f
-- Looking for log10f - found
-- Looking for pow
-- Looking for pow - found
-- Looking for powf
-- Looking for powf - found
-- Looking for scalbn
-- Looking for scalbn - found
-- Looking for scalbnf
-- Looking for scalbnf - found
-- Looking for sin
-- Looking for sin - found
-- Looking for sinf
-- Looking for sinf - found
-- Looking for sqrt
-- Looking for sqrt - found
-- Looking for sqrtf
-- Looking for sqrtf - found
-- Looking for tan
-- Looking for tan - found
-- Looking for tanf
-- Looking for tanf - found
-- Looking for acos
-- Looking for acos - found
-- Looking for acosf
-- Looking for acosf - found
-- Looking for asin
-- Looking for asin - found
-- Looking for asinf
-- Looking for asinf - found
-- Looking for trunc
-- Looking for trunc - found
-- Looking for truncf
-- Looking for truncf - found
-- Looking for iconv_open in iconv
-- Looking for iconv_open in iconv - not found
-- Looking for alloca.h
-- Looking for alloca.h - not found
-- Looking for alloca
-- Looking for alloca - not found
-- Performing Test HAVE_SA_SIGACTION
-- Performing Test HAVE_SA_SIGACTION - Failed
-- Performing Test HAVE_WIN32_CC
-- Performing Test HAVE_WIN32_CC - Success
-- Performing Test HAVE_XINPUT_H
-- Performing Test HAVE_XINPUT_H - Success
-- Performing Test HAVE_XINPUT_GAMEPAD_EX
-- Performing Test HAVE_XINPUT_GAMEPAD_EX - Failed
-- Performing Test HAVE_XINPUT_STATE_EX
-- Performing Test HAVE_XINPUT_STATE_EX - Failed
-- Looking for d3d9.h
-- Looking for d3d9.h - found
-- Looking for d3d11_1.h
-- Looking for d3d11_1.h - not found
-- Looking for ddraw.h
-- Looking for ddraw.h - found
-- Looking for dsound.h
-- Looking for dsound.h - found
-- Looking for dinput.h
-- Looking for dinput.h - found
-- Looking for dxgi.h
-- Looking for dxgi.h - found
-- Looking for mmdeviceapi.h
-- Looking for mmdeviceapi.h - not found
-- Looking for audioclient.h
-- Looking for audioclient.h - not found
-- Looking for sensorsapi.h
-- Looking for sensorsapi.h - not found

On 2020-10-11 22:29:22 +0000, Ozkan Sezer wrote:

autoconf-2.69 checks only stdlib.h, stdarg.h, string.h, and float.h in
AC_HEADER_STDC. This cmake version is more than overzealous to say the
least.

On 2020-10-11 23:41:35 +0000, Ozkan Sezer wrote:

Applied https://hg.libsdl.org/SDL/rev/0172679c8a8a
which fixes the issues for me. Closing this bug.

If this commit results in problems, drop a note here.

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

No branches or pull requests

1 participant