Skip to content

Commit 1038070

Browse files
rdmarkmsteinert
authored andcommitted
Check for and use no-undefined linker flag, explicitly link with libc
Check if the linker can link with '-Wl,--no-undefined' and apply the flag when linking libbstring Also for the sake of OpenBSD, look for and explicitly link with libc in order to address the linker error that the above flag revealed
1 parent c312c5e commit 1038070

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

bstring/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ libbstring = library(
66
version: '1.0.0',
77
soversion: '1',
88
include_directories: bstring_inc,
9+
dependencies: bstring_deps,
10+
link_args: linker_flags,
911
install: true,
1012
)
1113

meson.build

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ add_project_arguments('-fno-common', language: 'c')
1010
add_project_arguments('-fvisibility=hidden', language: 'c')
1111

1212
bstring_inc = include_directories(['.', 'bstring'])
13+
bstring_deps = []
14+
libc_dep = cc.find_library('c', required: false)
15+
16+
if libc_dep.found()
17+
bstring_deps += [libc_dep]
18+
endif
19+
20+
linker_flags = []
21+
22+
if cc.has_link_argument('-Wl,--no-undefined')
23+
linker_flags = ['-Wl,--no-undefined']
24+
endif
1325

1426
bgets_test_code = '''
1527
#include <stdio.h>

0 commit comments

Comments
 (0)