Commit b50e91d8
b50e91d843f5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified
Description
fix: spinel wrapper uses absolute paths for lib/ includes and runtime
Previously spinel wrapper emitted -Ilib/regexp (relative) and did not include -Ilib nor link libspinel_rt.a. Programs compiled from any directory other than the spinel install dir failed with "sp_runtime.h: No such file or directory".
Now the wrapper uses $DIR-based absolute paths:
- -I$DIR/lib (for sp_runtime.h)
- -I$DIR/lib/regexp (for re_internal.h, if regexp used)
- $DIR/lib/libspinel_rt.a (runtime library)
Legacy standalone libspre.a fallback retained for backward compat.
Tested: cd /tmp && spinel some.rb now succeeds.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- b50e91d843f5
- Parent
- c9a55e07391e
spinelmodifiedView file
@@ -117,12 +117,19 @@
117117
118118
# Step 3: Compile C -> binary119119
BIN_FILE="${OUTPUT:-$BASENAME}"120-
# Auto-detect regexp usage and link libspre.a120+
# Runtime library (bigint + regexp)121+
SP_RT_LIB="$DIR/lib/libspinel_rt.a"122+
INCLUDE_FLAGS="-I$DIR/lib"123+
if [ -f "$SP_RT_LIB" ]; then124+
EXTRA_FLAGS="$EXTRA_FLAGS $SP_RT_LIB"125+
fi126+
# Legacy: optional standalone regexp lib (retained for backward compat)121127
RE_LIB="$DIR/lib/regexp/libspre.a"122-
if grep -q 're_compile' "$C_FILE" 2>/dev/null && [ -f "$RE_LIB" ]; then123-
EXTRA_FLAGS="$EXTRA_FLAGS $RE_LIB -Ilib/regexp"128+
if grep -q 're_compile' "$C_FILE" 2>/dev/null && [ ! -f "$SP_RT_LIB" ] && [ -f "$RE_LIB" ]; then129+
EXTRA_FLAGS="$EXTRA_FLAGS $RE_LIB"124130
fi125-
$CC_CMD -O${OPT_LEVEL} -Wno-all -ffunction-sections -fdata-sections "$C_FILE" -lm $EXTRA_FLAGS -Wl,--gc-sections -o "$BIN_FILE"131+
INCLUDE_FLAGS="$INCLUDE_FLAGS -I$DIR/lib/regexp"132+
$CC_CMD -O${OPT_LEVEL} -Wno-all -ffunction-sections -fdata-sections $INCLUDE_FLAGS "$C_FILE" -lm $EXTRA_FLAGS -Wl,--gc-sections -o "$BIN_FILE"126133
if [ $? -ne 0 ]; then127134
echo "spinel: C compilation failed" >&2128135
exit 1