Skip to content

Commit

Permalink
[WIP] otel: fix linking on macOS and Ubuntu
Browse files Browse the repository at this point in the history
The static library is supposed to be specified prior to its
dependencies.
Also, no need to put an otel static library inside libnxt static
library, as we explicitely link unit binary with otel static library
anyway.

This fixes the following build problems:

- macOS:

      Finished `release` profile [optimized] target(s) in 58.07s
    AR     build/lib/libnxt.a
    LD     build/sbin/unitd
  ld: archive member 'libotel.a' not a mach-o file in '/private/tmp/unit-20241219-8965-yb46xp/build/lib/libnxt.a'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

- Ubuntu 22 (./configure --otel):

  LD     build/sbin/unitd
cc -Wl,-E  -o build/sbin/unitd -pipe -fPIC -fvisibility=hidden -fno-strict-overflow -funsigned-char -std=gnu11 -O -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -fno-strict-aliasing -Wmissing-prototypes -Werror -g    \
	build/src/nxt_main.o  build/lib/libnxt.a \
	-lm -lrt  -lpthread   \
                      \
                    -lpcre2-8 -lssl -lcrypto src/otel/target/release/libotel.a
/usr/bin/ld: src/otel/target/release/libotel.a(reqwest-97d1376dfb77d784.reqwest.cb371ce8e1e3945e-cgu.04.rcgu.o): in function `core::ptr::drop_in_place<alloc::vec::Vec<reqwest::tls::Certificate>>':
reqwest.cb371ce8e1e3945e-cgu.04:(.text._ZN4core3ptr69drop_in_place$LT$alloc..vec..Vec$LT$reqwest..tls..Certificate$GT$$GT$17h9b62679cc7161be5E+0x30): undefined reference to `X509_free'
  • Loading branch information
thresheek committed Dec 19, 2024
1 parent 27bde18 commit 18381b1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions auto/make
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ 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)
\$(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_LOC) \\
$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 @@ -379,7 +380,8 @@ $NXT_BUILD_DIR/sbin/$NXT_DAEMON: $NXT_BUILD_DIR/lib/$NXT_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_LOC) \\
$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

END

Expand Down

0 comments on commit 18381b1

Please sign in to comment.