Skip to content

Commit d0dbba3

Browse files
committed
auto/make: Fix various issues with building OTEL
There were at least a couple of issues with building OTEL support. It only worked with GNU make due to the use of ifeq, even gmake had some issues. Debug builds were broken due to trying to pass --debug to cargo which is the default and isn't a valid option. This 'fixes' things by doing 'release' builds of OTEL by default. Passing D=1 to make will generate 'debug' builds but this as previously with D= etc, only works with GNU make. We make use of the '--emit link=' rustc option to place the libotel.a static library into build/lib This is good, it consolidates the static libraries into one place and it simplifies the build scripts. While we're at it pretty print the cargo command by default. Fixes: 9d3dcb8 ("otel: add build tooling to include otel code") Link: <#1520 (comment)> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
1 parent 1ac4e40 commit d0dbba3

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

auto/make

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@ PP_AR := @echo ' AR '
1515
PP_LD := @echo ' LD '
1616
PP_VER := @echo ' VER '
1717
PP_SED := @echo ' SED '
18+
PP_CR := @echo ' CR '
1819

1920
CC = $CC
2021
AR = $AR
2122

2223
EXTRA_CFLAGS =
2324
CFLAGS = $NXT_CFLAGS $NXT_CC_OPT $CFLAGS \$(EXTRA_CFLAGS)
24-
RUST_FLAGS =
25-
NXT_OTEL_LIB_STATIC =
2625

2726
NXT_EXEC_LINK = $NXT_EXEC_LINK $NXT_LD_OPT
2827
NXT_SHARED_LOCAL_LINK = $NXT_SHARED_LOCAL_LINK $NXT_LD_OPT
2928
NXT_MODULE_LINK = $NXT_MODULE_LINK
3029

30+
NXT_OTEL_LIB_STATIC =
31+
3132
all: $NXT_DAEMON manpage
3233

3334
.PHONY: $NXT_DAEMON manpage
@@ -37,6 +38,18 @@ manpage: $NXT_BUILD_DIR/share/man/man8/unitd.8
3738
END
3839

3940

41+
if [ $NXT_OTEL = YES ]; then
42+
43+
cat << END >> $NXT_MAKEFILE
44+
45+
RUST_FLAGS = --release
46+
NXT_OTEL_LIB_STATIC = $NXT_BUILD_DIR/lib/libotel.a
47+
48+
END
49+
50+
fi
51+
52+
4053
NXT_OS=$(uname -s)
4154
NXT_GNU_MAKE=$(make --version | grep GNU || true)
4255

@@ -63,9 +76,7 @@ D := 0
6376

6477
ifeq (\$D,1)
6578
CFLAGS += -O0
66-
RUST_FLAGS += --debug
67-
else
68-
RUST_FLAGS += --release
79+
RUST_FLAGS =
6980
endif
7081

7182
# Optionally disable -Werror with
@@ -80,18 +91,6 @@ END
8091

8192
fi
8293

83-
# potentially set otel lib location
84-
if [ $NXT_OTEL = YES ]; then
85-
cat << END >> $NXT_MAKEFILE
86-
87-
ifeq (\$D,1)
88-
NXT_OTEL_LIB_STATIC = $NXT_OTEL_LIB_DIR/target/debug/libotel.a
89-
else
90-
NXT_OTEL_LIB_STATIC = $NXT_OTEL_LIB_DIR/target/release/libotel.a
91-
endif
92-
93-
END
94-
fi
9594

9695
# The include paths list.
9796

@@ -587,6 +586,9 @@ NXT_OTEL_DEPS=" \
587586
cat << END >> $NXT_MAKEFILE
588587

589588
\$(NXT_OTEL_LIB_STATIC): $NXT_OTEL_DEPS
590-
cargo build \$(RUST_FLAGS) --manifest-path $NXT_OTEL_LIB_DIR/Cargo.toml
589+
\$(PP_CR) \$@
590+
\$(v)cargo rustc \$(RUST_FLAGS) \\
591+
--manifest-path $NXT_OTEL_LIB_DIR/Cargo.toml \\
592+
-- --emit link=../../$NXT_BUILD_DIR/lib/libotel.a
591593
END
592594
fi

0 commit comments

Comments
 (0)