Skip to content

Commit

Permalink
build: do not include config.h globally
Browse files Browse the repository at this point in the history
The python build breaks because of libnvme and the swig generator define
variations of fallthrough. Let's only include the config.h for the
libraries.

Signed-off-by: Daniel Wagner <[email protected]>
  • Loading branch information
igaw committed Feb 27, 2025
1 parent 020b979 commit 0d8d0a5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
8 changes: 1 addition & 7 deletions internal/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,4 @@ config_dep = declare_dependency(
sources: config_h)

config_h_path = meson.current_build_dir() / 'config.h'

add_project_arguments(
[
'-include', config_h_path,
],
language : 'c',
)
config_h_arg = [ '-include', config_h_path ]
10 changes: 0 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,6 @@ conf.set(
),
description: 'Is network address and service translation available'
)
conf.set(
'HAVE_GLIBC_IOCTL',
cc.compiles(
'''#include <sys/ioctl.h>
int ioctl(int fd, unsigned long request, ...);
''',
name: 'ioctl has glibc-style prototype'
),
description: 'Is ioctl the glibc interface (rather than POSIX)'
)
dl_dep = dependency('dl', required: false)
conf.set(
'HAVE_LIBC_DLSYM',
Expand Down
3 changes: 3 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ libnvme = library(
link_args: ['-Wl,--version-script=' + version_script_arg],
dependencies: deps,
link_depends: mapfile,
c_args: config_h_arg,
include_directories: [incdir, internal_incdir],
install: true,
link_with: libccan,
Expand All @@ -81,6 +82,7 @@ libnvme_mi = library(
'nvme-mi', # produces libnvme-mi.so
mi_sources,
version: library_version,
c_args: config_h_arg,
link_args: ['-Wl,--version-script=' + mi_version_script_arg],
dependencies: mi_deps,
link_depends: mi_mapfile,
Expand All @@ -100,6 +102,7 @@ libnvme_mi_test = library(
'nvme-mi-test', # produces libnvme-mi-test.so
mi_sources,
dependencies: mi_deps,
c_args: config_h_arg,
include_directories: [incdir, internal_incdir],
install: false,
link_with: libccan,
Expand Down
17 changes: 15 additions & 2 deletions test/ioctl/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
mock_conf = configuration_data()

mock_conf.set(
'HAVE_GLIBC_IOCTL',
cc.compiles(
'''#include <sys/ioctl.h>
int ioctl(int fd, unsigned long request, ...);
''',
name: 'ioctl has glibc-style prototype'
),
description: 'Is ioctl the glibc interface (rather than POSIX)'
)

mock_ioctl = library(
'mock-ioctl',
['mock.c', 'util.c'],
dependencies: [dl_dep]
)
dependencies: [dl_dep],
c_args: ['-DHAVE_GLIBC_IOCTL=' + (mock_conf.get('HAVE_GLIBC_IOCTL') ? '1' : '0')])

# Add mock-ioctl to the LD_PRELOAD path so it overrides libc.
# Append to LD_PRELOAD so existing libraries, e.g. libasan, are kept.
Expand Down

0 comments on commit 0d8d0a5

Please sign in to comment.