Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTEL build fixes #1527

Merged
merged 6 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 41 additions & 33 deletions auto/make
Original file line number Diff line number Diff line change
Expand Up @@ -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_LOC =

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
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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_LOC = $NXT_OTEL_LIB_DIR/target/debug/libotel.a
else
NXT_OTEL_LIB_LOC = $NXT_OTEL_LIB_DIR/target/release/libotel.a
endif

END
fi

# The include paths list.

Expand Down Expand Up @@ -154,14 +153,15 @@ cat << END >> $NXT_MAKEFILE

libnxt: $NXT_BUILD_DIR/lib/$NXT_LIB_SHARED $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC

$NXT_BUILD_DIR/lib/$NXT_LIB_SHARED: \$(NXT_LIB_OBJS) \$(NXT_OTEL_LIB_LOC)
$NXT_BUILD_DIR/lib/$NXT_LIB_SHARED: \$(NXT_LIB_OBJS) \$(NXT_OTEL_LIB_STATIC)
\$(PP_LD) \$@
\$(v)\$(NXT_SHARED_LOCAL_LINK) -o \$@ \$(NXT_LIB_OBJS) \\
$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS \$(NXT_OTEL_LIB_LOC)
\$(NXT_OTEL_LIB_STATIC) \\
$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC: \$(NXT_LIB_OBJS) \$(NXT_OTEL_LIB_LOC)
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC: \$(NXT_LIB_OBJS)
\$(PP_AR) \$@
\$(v)$NXT_STATIC_LINK \$@ \$(NXT_LIB_OBJS) \$(NXT_OTEL_LIB_LOC)
\$(v)$NXT_STATIC_LINK \$@ \$(NXT_LIB_OBJS)

$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC: \$(NXT_LIB_UNIT_OBJS) \\
$NXT_BUILD_DIR/share/pkgconfig/unit.pc \\
Expand Down Expand Up @@ -264,36 +264,40 @@ tests: $NXT_BUILD_DIR/tests $NXT_BUILD_DIR/utf8_file_name_test \\
$NXT_BUILD_DIR/unit_websocket_echo

$NXT_BUILD_DIR/tests: \$(NXT_TEST_OBJS) \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
\$(NXT_OTEL_LIB_STATIC)
\$(PP_LD) \$@
\$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/tests \\
\$(CFLAGS) \$(NXT_TEST_OBJS) \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \$(NXT_OTEL_LIB_STATIC) \\
$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

$NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
\$(NXT_OTEL_LIB_STATIC)
\$(PP_LD) \$@
\$(v)\$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
-o $NXT_BUILD_DIR/utf8_file_name_test \\
$NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \$(NXT_OTEL_LIB_STATIC) \\
$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

$NXT_BUILD_DIR/ncq_test: $NXT_BUILD_DIR/src/test/nxt_ncq_test.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
\$(NXT_OTEL_LIB_STATIC)
\$(PP_LD) \$@
\$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/ncq_test \\
\$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_ncq_test.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \$(NXT_OTEL_LIB_STATIC) \\
$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

$NXT_BUILD_DIR/vbcq_test: $NXT_BUILD_DIR/src/test/nxt_vbcq_test.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
\$(NXT_OTEL_LIB_STATIC)
\$(PP_LD) \$@
\$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/vbcq_test \\
\$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_vbcq_test.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \$(NXT_OTEL_LIB_STATIC) \\
$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

$NXT_BUILD_DIR/unit_app_test: $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\
Expand Down Expand Up @@ -375,11 +379,12 @@ $echo >> $NXT_MAKEFILE
cat << END >> $NXT_MAKEFILE

$NXT_BUILD_DIR/sbin/$NXT_DAEMON: $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
\$(NXT_OBJS) \$(NXT_OTEL_LIB_LOC)
\$(NXT_OBJS) \$(NXT_OTEL_LIB_STATIC)
\$(PP_LD) \$@
\$(v)\$(NXT_EXEC_LINK) -o \$@ \$(CFLAGS) \\
\$(NXT_OBJS) $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS \$(NXT_OTEL_LIB_LOC)
\$(NXT_OTEL_LIB_STATIC) \\
$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

END

Expand Down Expand Up @@ -580,7 +585,10 @@ NXT_OTEL_DEPS=" \

cat << END >> $NXT_MAKEFILE

\$(NXT_OTEL_LIB_LOC): $NXT_OTEL_DEPS
cargo build \$(RUST_FLAGS) --manifest-path $NXT_OTEL_LIB_DIR/Cargo.toml
\$(NXT_OTEL_LIB_STATIC): $NXT_OTEL_DEPS
\$(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
56 changes: 33 additions & 23 deletions auto/otel
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,44 @@ if [ $NXT_OTEL = YES ]; then
fi
$echo "found"

$echo -n " - "

nxt_feature="OpenSSL library"
nxt_feature_run=yes
nxt_feature_incs=
nxt_feature_libs="-lssl -lcrypto"
nxt_feature_test="#include <openssl/ssl.h>

int main(void) {
SSL_library_init();
return 0;
}"
. auto/feature

if [ ! $nxt_found = yes ]; then
$echo
$echo $0: error: OpenTelemetry support requires OpenSSL.
$echo
exit 1;
fi
case "$NXT_SYSTEM" in
Darwin)
NXT_OTEL_LIBS="-framework CoreFoundation -framework Security -framework SystemConfiguration"

NXT_OTEL_LIBS="-lssl -lcrypto"

cat << END >> $NXT_AUTO_CONFIG_H
cat << END >> $NXT_AUTO_CONFIG_H

#ifndef NXT_HAVE_OTEL
#define NXT_HAVE_OTEL 1
#endif

END
;;
*)

$echo -n " - "

nxt_feature="OpenSSL library"
nxt_feature_name=NXT_HAVE_OTEL
nxt_feature_run=yes
nxt_feature_incs=
nxt_feature_libs="-lssl -lcrypto"
nxt_feature_test="#include <openssl/ssl.h>

int main(void) {
SSL_library_init();
return 0;
}"
. auto/feature

if [ ! $nxt_found = yes ]; then
$echo
$echo $0: error: OpenTelemetry support requires OpenSSL.
$echo
exit 1;
fi

NXT_OTEL_LIBS="-lssl -lcrypto"
;;
esac

fi
Loading