meson: Use global function in argp check
authorKhem Raj <raj.khem@gmail.com>
Wed, 22 Feb 2023 22:55:07 +0000 (14:55 -0800)
committerKhem Raj <raj.khem@gmail.com>
Wed, 22 Feb 2023 22:58:32 +0000 (14:58 -0800)
clang is optimizing away parse_opt() since its marked static and not
used in main(), make life a bit harder for clang :)
removing static now emits the global symbols to be resolved during link
and when libargp is missing the error is thrown rightly

riscv64-yoe-linux-musl-ld: /tmp/a-5ba039.o: in function `.Lpcrel_hi0':
a.c:(.text+0x44): undefined reference to `argp_state_help'
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
meson.build

index 3b92d580dafd465a5349adb8eacd5c3d35ca92f8..ab54abdc7b77f6b2331a3871a09557ac615d5110 100644 (file)
@@ -57,7 +57,7 @@ if host_machine.system() == 'windows'
 endif
 
 # argp-standalone dependency (if required)
-if build_machine.system() == 'windows' or build_machine.system() == 'darwin' or build_machine.system() == 'freebsd' or not cc.links('#include <argp.h>\nstatic error_t parse_opt (int key, char *arg, struct argp_state *state) { argp_usage(state); return 0; }; void main() {}')
+if build_machine.system() == 'windows' or build_machine.system() == 'darwin' or build_machine.system() == 'freebsd' or not cc.links('#include <argp.h>\nerror_t parse_opt (int key, char *arg, struct argp_state *state) { argp_usage(state); return 0; }; void main() {}')
     argplib = cc.find_library('argp', has_headers : ['argp.h'], required: false)
     if not argplib.found()
         argplib = dependency('argp-standalone')