summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2025-01-09 03:55:44 +0000
committerAndrew Clayton <a.clayton@nginx.com>2025-01-10 04:16:09 +0000
commitd0dbba3b9f2f6a2e0e0d6e9862a4c6c1ab603242 (patch)
treee476220adf71766e59bca389ec1f7e58faecb803
parent1ac4e40941df4fac62c471545aec3e3c75abe50e (diff)
downloadunit-d0dbba3b9f2f6a2e0e0d6e9862a4c6c1ab603242.tar.gz
unit-d0dbba3b9f2f6a2e0e0d6e9862a4c6c1ab603242.tar.bz2
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: 9d3dcb800 ("otel: add build tooling to include otel code") Link: <https://github.com/nginx/unit/pull/1520#issuecomment-2556265063> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
-rw-r--r--auto/make38
1 files changed, 20 insertions, 18 deletions
diff --git a/auto/make b/auto/make
index 2468ea39..4320f629 100644
--- a/auto/make
+++ b/auto/make
@@ -15,19 +15,20 @@ PP_AR := @echo ' AR '
PP_LD := @echo ' LD '
PP_VER := @echo ' VER '
PP_SED := @echo ' SED '
+PP_CR := @echo ' CR '
CC = $CC
AR = $AR
EXTRA_CFLAGS =
CFLAGS = $NXT_CFLAGS $NXT_CC_OPT $CFLAGS \$(EXTRA_CFLAGS)
-RUST_FLAGS =
-NXT_OTEL_LIB_STATIC =
NXT_EXEC_LINK = $NXT_EXEC_LINK $NXT_LD_OPT
NXT_SHARED_LOCAL_LINK = $NXT_SHARED_LOCAL_LINK $NXT_LD_OPT
NXT_MODULE_LINK = $NXT_MODULE_LINK
+NXT_OTEL_LIB_STATIC =
+
all: $NXT_DAEMON manpage
.PHONY: $NXT_DAEMON manpage
@@ -37,6 +38,18 @@ manpage: $NXT_BUILD_DIR/share/man/man8/unitd.8
END
+if [ $NXT_OTEL = YES ]; then
+
+ cat << END >> $NXT_MAKEFILE
+
+RUST_FLAGS = --release
+NXT_OTEL_LIB_STATIC = $NXT_BUILD_DIR/lib/libotel.a
+
+END
+
+fi
+
+
NXT_OS=$(uname -s)
NXT_GNU_MAKE=$(make --version | grep GNU || true)
@@ -63,9 +76,7 @@ D := 0
ifeq (\$D,1)
CFLAGS += -O0
- RUST_FLAGS += --debug
-else
- RUST_FLAGS += --release
+ RUST_FLAGS =
endif
# Optionally disable -Werror with
@@ -80,18 +91,6 @@ END
fi
-# potentially set otel lib location
-if [ $NXT_OTEL = YES ]; then
-cat << END >> $NXT_MAKEFILE
-
-ifeq (\$D,1)
- NXT_OTEL_LIB_STATIC = $NXT_OTEL_LIB_DIR/target/debug/libotel.a
-else
- NXT_OTEL_LIB_STATIC = $NXT_OTEL_LIB_DIR/target/release/libotel.a
-endif
-
-END
-fi
# The include paths list.
@@ -587,6 +586,9 @@ NXT_OTEL_DEPS=" \
cat << END >> $NXT_MAKEFILE
\$(NXT_OTEL_LIB_STATIC): $NXT_OTEL_DEPS
- cargo build \$(RUST_FLAGS) --manifest-path $NXT_OTEL_LIB_DIR/Cargo.toml
+ \$(PP_CR) \$@
+ \$(v)cargo rustc \$(RUST_FLAGS) \\
+ --manifest-path $NXT_OTEL_LIB_DIR/Cargo.toml \\
+ -- --emit link=../../$NXT_BUILD_DIR/lib/libotel.a
END
fi