Skip to content

Commit d98d2d2

Browse files
authored
Merge pull request #533 from igaw/static-build
Support static builds
2 parents 6be5fc6 + 0a92113 commit d98d2d2

4 files changed

Lines changed: 69 additions & 19 deletions

File tree

.github/cross/ubuntu-static.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[properties]
2+
c_args = '-static'
3+
cpp_args = c_args
4+
5+
[binaries]
6+
c = '/usr/bin/gcc'

.github/workflows/meson.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
name: Linux_Meson_log
113113
path: build/meson-logs/meson-log.txt
114114

115-
build-static:
115+
build-with-libray-static:
116116
runs-on: ubuntu-latest
117117
steps:
118118
- name: install libraries
@@ -134,6 +134,28 @@ jobs:
134134
name: Linux_Meson_log
135135
path: build/meson-logs/meson-log.txt
136136

137+
build-static:
138+
runs-on: ubuntu-latest
139+
steps:
140+
- name: install libraries
141+
run: sudo apt-get install -y libpam-dev libcap-ng-dev
142+
- uses: actions/checkout@v3
143+
- uses: actions/setup-python@v4
144+
with:
145+
python-version: '3.x'
146+
- uses: BSFishy/[email protected]
147+
with:
148+
setup-options: --werror --wrap-mode=forcefallback --cross-file=.github/cross/ubuntu-static.txt --default-library=static
149+
options: --verbose
150+
action: test
151+
meson-version: 0.61.2
152+
# Preserve meson's log file on failure
153+
- uses: actions/upload-artifact@v3
154+
if: failure()
155+
with:
156+
name: Linux_Meson_log
157+
path: build/meson-logs/meson-log.txt
158+
137159
code-coverage:
138160
runs-on: ubuntu-latest
139161
steps:

meson.build

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,20 @@ endif
9191

9292
# Check for libsystemd availability. Optional, only required for MCTP dbus scan
9393
libsystemd_dep = dependency('libsystemd', version: '>219', required: false)
94-
conf.set('CONFIG_LIBSYSTEMD', libsystemd_dep.found(), description: 'Is libsystemd(>219) available?')
94+
if libsystemd_dep.found()
95+
if cc.links('''#include <systemd/sd-bus.h>
96+
int main(void) {
97+
struct sd_bus *ret;
98+
return sd_bus_default(&ret);
99+
}
100+
''',
101+
dependencies: libsystemd_dep,
102+
name: 'Link check')
103+
conf.set('CONFIG_LIBSYSTEMD', libsystemd_dep.found(), description: 'Is libsystemd(>219) available?')
104+
else
105+
libsystemd_dep = dependency('', required: false)
106+
endif
107+
endif
95108

96109
# local (cross-compilable) implementations of ccan configure steps
97110
conf.set10(
@@ -180,24 +193,20 @@ conf.set10(
180193
description: 'Is linux/mctp.h include-able?'
181194
)
182195

183-
if meson.version().version_compare('>= 0.48')
184-
has_fallthrough = cc.has_function_attribute('fallthrough')
185-
else
186-
has_fallthrough = cc.compiles(
187-
'''int main(int argc, char **argv) {
188-
switch(argc) {
189-
case 0:
190-
__attribute__((__fallthrough__));
191-
case 1:
192-
return 1;
193-
}
194-
return 0;
195-
}
196-
''',
197-
name: 'has fallthrough')
198-
endif
196+
conf.set(
197+
'HAVE_LIBNSS',
198+
cc.links(
199+
'''int main(int argc, char **argv) {
200+
struct addrinfo hints, *result;
201+
return getaddrinfo(argv[1], argv[2], &hints, &result);
202+
}
203+
''',
204+
name: 'havelibnss',
205+
),
206+
description: 'Is network address and service translation available'
207+
)
199208

200-
if has_fallthrough
209+
if cc.has_function_attribute('fallthrough')
201210
conf.set('fallthrough', '__attribute__((__fallthrough__))')
202211
else
203212
conf.set('fallthrough', 'do {} while (0) /* fallthrough */')

src/nvme/util.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ const char *nvme_errno_to_string(int status)
573573
return s;
574574
}
575575

576+
#ifdef HAVE_LIBNSS
576577
char *hostname2traddr(struct nvme_root *r, const char *traddr)
577578
{
578579
struct addrinfo *host_info, hints = {.ai_family = AF_UNSPEC};
@@ -617,6 +618,18 @@ char *hostname2traddr(struct nvme_root *r, const char *traddr)
617618
return ret_traddr;
618619
}
619620

621+
#else /* !HAVE_LIBNSS */
622+
623+
char *hostname2traddr(struct nvme_root *r, const char *traddr)
624+
{
625+
nvme_msg(NULL, LOG_ERR, "No support for hostname IP address resolution; " \
626+
"recompile with libnss support.\n");
627+
628+
errno = -ENOTSUP;
629+
return NULL;
630+
}
631+
#endif /* HAVE_LIBNSS */
632+
620633
char *startswith(const char *s, const char *prefix)
621634
{
622635
size_t l;

0 commit comments

Comments
 (0)