fix(ci): use soul.c-first link with --allow-multiple-definition
Linux elb generates individual .c files; soul.c does not contain merged imports (unlike macOS elb which produces a unified file). Re-link all dist/*.c manually with soul.c listed first so its real main() wins, and --allow-multiple-definition to silence GNU ld's duplicate symbol errors. All duplicates are identical (same El source, different compile units).
This commit is contained in:
@@ -109,21 +109,26 @@ jobs:
|
|||||||
ELC=/opt/el/dist/platform/elc
|
ELC=/opt/el/dist/platform/elc
|
||||||
RUNTIME=/opt/el/runtime
|
RUNTIME=/opt/el/runtime
|
||||||
|
|
||||||
# Compile all El modules to C (may fail at link on Linux: the El compiler
|
# Compile all El modules to C.
|
||||||
# inlines imported modules into each module's .c file, producing duplicate
|
# This step will fail at link on Linux: the El compiler inlines imported
|
||||||
# symbol definitions that GNU ld rejects as errors. macOS ld accepts them
|
# modules into each module's .c file, producing duplicate strong symbol
|
||||||
# silently. We ignore the link failure and re-link manually below.)
|
# definitions. GNU ld rejects these; macOS ld accepts them silently.
|
||||||
|
# We capture the link failure and re-link manually below.
|
||||||
$ELB --elc=$ELC --runtime=$RUNTIME/el_runtime.c || true
|
$ELB --elc=$ELC --runtime=$RUNTIME/el_runtime.c || true
|
||||||
|
|
||||||
# soul.c is a fully self-contained merged file — every function from every
|
# Re-link with soul.c listed first so its real main() (from the cgi block)
|
||||||
# imported module is inlined into it. Link only soul.c against el_runtime.c;
|
# wins over the stub main()s generated in every other module.
|
||||||
# this avoids all duplicate-symbol conflicts from the individual module files.
|
# --allow-multiple-definition tells GNU ld to pick the first definition
|
||||||
|
# for each duplicate symbol — safe here because all duplicates are identical
|
||||||
|
# (same El source compiled independently into multiple .c files).
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
OTHER_C=$(ls dist/*.c | grep -v '/soul\.c$' | sort | tr '\n' ' ')
|
||||||
cc -O2 -DHAVE_CURL \
|
cc -O2 -DHAVE_CURL \
|
||||||
-I$RUNTIME \
|
-I$RUNTIME \
|
||||||
dist/soul.c \
|
dist/soul.c $OTHER_C \
|
||||||
$RUNTIME/el_runtime.c \
|
$RUNTIME/el_runtime.c \
|
||||||
-lssl -lcrypto -lcurl -lpthread -lm \
|
-lssl -lcrypto -lcurl -lpthread -lm \
|
||||||
|
-Wl,--allow-multiple-definition \
|
||||||
-o dist/neuron
|
-o dist/neuron
|
||||||
|
|
||||||
ls -lh dist/neuron
|
ls -lh dist/neuron
|
||||||
|
|||||||
Reference in New Issue
Block a user