Skip to content

Commit a252b3b

Browse files
committed
fix broken includes for the uuid.h header
Per `man 3 uuid`, the correct include is `<uuid.h>`, and correspondingly the util-linux build system installs the uuid.h file to `$(includedir)/uuid/` and uuid.pc adds `-I${includedir}/uuid` to the dependency Cflags. Including it as `<uuid/uuid.h>` simply fails altogether. The exception is if, by coincidence, the libuuid includedir happens to be the same as one of the compiler's own internal include directories... which is pretty common if that is `/usr/include`. In this case, `<uuid/uuid.h>` fails to be found in the uuid dependency's export directories, but the compiler picks up a copy in its builtin search path. In other cases, such as when util-linux is compiled into a custom prefix and added to the PKG_CONFIG_PATH, it either: - fails with missing header errors, if libuuid-dev is not installed - seems to succeed, but compiles against a different version of the headers than the library that is linked to, resulting in potentially various problems from bizarre linker errors, to subtly broken incompatible symbols that crash, or corrupt the results The problem is even worse if you try to use util-linux as a subproject dependency fallback. In this case, `<uuid.h>` is correctly exported, but there is no disk location for `<uuid/uuid.h>` and absolutely no way to generate such a location in the builddir. This completely prevents the use of subproject fallbacks. Once the header include is renamed, it is revealed that the example and test executables don't correctly build as they depend on the full public interface of libnvme, which includes the public compile interface of libuuid due to `libnvme.h` including `uuid.h`. Update all executables to depend on the full public interface of libnvme_dep instead of simply linking to the library name on its own.
1 parent 7f76c0b commit a252b3b

6 files changed

Lines changed: 13 additions & 14 deletions

File tree

examples/meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
executable(
99
'telemetry-listen',
1010
['telemetry-listen.c'],
11-
link_with: libnvme,
11+
dependencies: libnvme_dep,
1212
include_directories: [incdir, internal_incdir]
1313
)
1414

1515
executable(
1616
'display-columnar',
1717
['display-columnar.c'],
18-
link_with: libnvme,
18+
dependencies: libnvme_dep,
1919
include_directories: [incdir, internal_incdir]
2020
)
2121

2222
executable(
2323
'display-tree',
2424
['display-tree.c'],
25-
link_with: libnvme,
25+
dependencies: libnvme_dep,
2626
include_directories: [incdir, internal_incdir]
2727
)
2828

2929
executable(
3030
'discover-loop',
3131
['discover-loop.c'],
32-
link_with: libnvme,
32+
dependencies: libnvme_dep,
3333
include_directories: [incdir, internal_incdir]
3434
)

libnvme/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ if have_python_support
2929
pynvme_clib = python3.extension_module(
3030
'_nvme',
3131
pymod_swig[1],
32-
dependencies : py3_dep,
32+
dependencies : [libnvme_dep, py3_dep],
3333
include_directories: [incdir, internal_incdir],
34-
link_with: [libnvme, libccan],
34+
link_with: [libccan],
3535
install: true,
3636
subdir: 'libnvme',
3737
)

src/nvme/private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "fabrics.h"
1515

16-
#include <uuid/uuid.h>
16+
#include <uuid.h>
1717

1818

1919
extern const char *nvme_ctrl_sysfs_dir;

src/nvme/tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <stddef.h>
1616

1717
#include <sys/types.h>
18-
#include <uuid/uuid.h>
18+
#include <uuid.h>
1919

2020
#include "ioctl.h"
2121
#include "util.h"

test/meson.build

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,27 @@
1212
main = executable(
1313
'main-test',
1414
['test.c'],
15-
dependencies: libuuid_dep,
16-
link_with: libnvme,
15+
dependencies: libnvme_dep,
1716
include_directories: [incdir, internal_incdir]
1817
)
1918

2019
cpp = executable(
2120
'test-cpp',
2221
['cpp.cc'],
23-
link_with: libnvme,
22+
dependencies: libnvme_dep,
2423
include_directories: [incdir, internal_incdir]
2524
)
2625

2726
register = executable(
2827
'test-register',
2928
['register.c'],
30-
link_with: libnvme,
29+
dependencies: libnvme_dep,
3130
include_directories: [incdir, internal_incdir]
3231
)
3332

3433
zns = executable(
3534
'test-zns',
3635
['zns.c'],
37-
link_with: libnvme,
36+
dependencies: libnvme_dep,
3837
include_directories: [incdir, internal_incdir]
3938
)

test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <string.h>
2020
#include <stdbool.h>
2121
#include <inttypes.h>
22-
#include <uuid/uuid.h>
22+
#include <uuid.h>
2323
#include <libnvme.h>
2424

2525
#include <ccan/endian/endian.h>

0 commit comments

Comments
 (0)