Opened 4 months ago

Last modified 4 months ago

#70471 new defect

meson checks for some functions are broken are return false positives

Reported by: barracuda156 Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.9.3
Keywords: Cc: SoapZA, reneeotten (Renee Otten)
Port: meson

Description (last modified by barracuda156)

Issue with upstream: https://github.com/mesonbuild/meson/issues/13495

Got this when preparing an update for netatalk, switching to meson:

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 

Notice, legacy-support is not used (I even tried deactivating it), so strndup and strnlen are not available. But both are misdetected as present.

Change History (1)

comment:1 Changed 4 months ago by barracuda156

Description: modified (diff)
Note: See TracTickets for help on using tickets.