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

Meson misdetects some functions as present when they are not #13495

Open
barracuda156 opened this issue Jul 31, 2024 · 0 comments
Open

Meson misdetects some functions as present when they are not #13495

barracuda156 opened this issue Jul 31, 2024 · 0 comments

Comments

@barracuda156
Copy link
Contributor

Describe the bug
Meson misdetects strnlen and strndup as present when they are not.
Example:

Running compile:
Working directory:  /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmp81w99i2x
Code:

        #define strnlen meson_disable_define_of_strnlen
        
        #include <limits.h>
        #undef strnlen
        
        #ifdef __cplusplus
        extern "C"
        #endif
        char strnlen (void);
        
        #if defined __stub_strnlen || defined __stub___strnlen
        fail fail fail this function is not going to work
        #endif
        
        int main(void) {
          return strnlen ();
        }
-----------
Command line: `/opt/local/bin/gcc-mp-14 -L/opt/local/libexec/openssl3/lib -L/opt/local/lib -L/opt/local/lib/db48 -I/opt/local/libexec/openssl3/include -I/opt/local/include/db48 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmp81w99i2x/testfile.c -o /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmp81w99i2x/output.exe -pipe -Os -arch ppc -O0 -std=c11 -Wl,-headerpad_max_install_names` -> 1
stderr:
Undefined symbols:
  "_strnlen", referenced from:
      _main in ccBiqEIa.o
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
-----------
Running compile:
Working directory:  /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmp5uqy20q2
Code:

        int main(void) {

        /* With some toolchains (MSYS2/mingw for example) the compiler
         * provides various builtins which are not really implemented and
         * fall back to the stdlib where they aren't provided and fail at
         * build/link time. In case the user provides a header, including
         * the header didn't lead to the function being defined, and the
         * function we are checking isn't a builtin itself we assume the
         * builtin is not functional and we just error out. */
        #if !1 && !defined(strnlen) && !0
            #error "No definition for __builtin_strnlen found in the prefix"
        #endif

        #ifdef __has_builtin
            #if !__has_builtin(__builtin_strnlen)
                #error "__builtin_strnlen not found"
            #endif
        #elif ! defined(strnlen)
            __builtin_strnlen;
        #endif
        return 0;
        }
-----------
Command line: `/opt/local/bin/gcc-mp-14 -L/opt/local/libexec/openssl3/lib -L/opt/local/lib -L/opt/local/lib/db48 -I/opt/local/libexec/openssl3/include -I/opt/local/include/db48 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmp5uqy20q2/testfile.c -o /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmp5uqy20q2/output.exe -pipe -Os -arch ppc -O0 -std=c11 -Wl,-headerpad_max_install_names` -> 0
Checking for function "strnlen" : YES 
Running compile:
Working directory:  /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmpwm47abeg
Code:

        #define strndup meson_disable_define_of_strndup
        
        #include <limits.h>
        #undef strndup
        
        #ifdef __cplusplus
        extern "C"
        #endif
        char strndup (void);
        
        #if defined __stub_strndup || defined __stub___strndup
        fail fail fail this function is not going to work
        #endif
        
        int main(void) {
          return strndup ();
        }
-----------
Command line: `/opt/local/bin/gcc-mp-14 -L/opt/local/libexec/openssl3/lib -L/opt/local/lib -L/opt/local/lib/db48 -I/opt/local/libexec/openssl3/include -I/opt/local/include/db48 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmpwm47abeg/testfile.c -o /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmpwm47abeg/output.exe -pipe -Os -arch ppc -O0 -std=c11 -Wl,-headerpad_max_install_names` -> 1
stderr:
Undefined symbols:
  "_strndup", referenced from:
      _main in ccYNuFXj.o
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
-----------
Running compile:
Working directory:  /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmpuk6wfim1
Code:

        int main(void) {

        /* With some toolchains (MSYS2/mingw for example) the compiler
         * provides various builtins which are not really implemented and
         * fall back to the stdlib where they aren't provided and fail at
         * build/link time. In case the user provides a header, including
         * the header didn't lead to the function being defined, and the
         * function we are checking isn't a builtin itself we assume the
         * builtin is not functional and we just error out. */
        #if !1 && !defined(strndup) && !0
            #error "No definition for __builtin_strndup found in the prefix"
        #endif

        #ifdef __has_builtin
            #if !__has_builtin(__builtin_strndup)
                #error "__builtin_strndup not found"
            #endif
        #elif ! defined(strndup)
            __builtin_strndup;
        #endif
        return 0;
        }
-----------
Command line: `/opt/local/bin/gcc-mp-14 -L/opt/local/libexec/openssl3/lib -L/opt/local/lib -L/opt/local/lib/db48 -I/opt/local/libexec/openssl3/include -I/opt/local/include/db48 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmpuk6wfim1/testfile.c -o /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_net_netatalk/netatalk/work/build/meson-private/tmpuk6wfim1/output.exe -pipe -Os -arch ppc -O0 -std=c11 -Wl,-headerpad_max_install_names` -> 0
Checking for function "strndup" : YES 

To Reproduce
Build something using meson which has related checks. For example, netatalk.

Expected behavior
Support for these should be accurately determined.

Meson 1.5.1

P. S. Looks similar to the old bug: #3672

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

No branches or pull requests

1 participant