Index: build/tcllibc.sh ================================================================== --- build/tcllibc.sh +++ build/tcllibc.sh @@ -1,7 +1,11 @@ #! /usr/bin/env bash +cflags=(-DUSE_TCL_STUBS=1 -fPIC) +ldflags=() +libs=(-ltclstub8.6) + inFiles=( ../../tcllib-fossil/modules/tcllibc.tcl ../../tcllib-fossil/modules/md4/md4c.tcl ../../tcllib-fossil/modules/struct/graph_c.tcl ../../tcllib-fossil/modules/base32/base32_c.tcl @@ -49,13 +53,13 @@ for input in "${inFiles[@]}"; do out="${outDir}/$(basename "${input}" .tcl)" ./tcc-critcl-to-c.tcl --mode direct "${input}" > "${out}.c" - cflags=($(awk '/^CLI:/{ gsub(/^CLI:/, ""); print; }' < "${out}.c")) + input_cflags=($(awk '/^CLI:/{ gsub(/^CLI:/, ""); print; }' < "${out}.c")) - "${CC:-cc}" -fPIC -Dinline= -o "${out}.o" "${cflags[@]}" -c "${out}.c" || continue + "${CC:-cc}" "${cflags[@]}" -Dinline= -o "${out}.o" "${input_cflags[@]}" -c "${out}.c" || continue done ( cd "${outDir}" || exit 1 @@ -99,11 +103,22 @@ return(TCL_OK); } _EOF_ - "${CC:-cc}" -fPIC -o base.o -c base.c + "${CC:-cc}" "${cflags[@]}" -o base.o -c base.c ) -"${CC:-cc}" -fPIC -shared -o tcllibc.so "${outDir}"/*.o +cat << \_EOF_ > "${outDir}/version-script" +{ + global: + Tcllibc_Init; + local: + *; +}; +_EOF_ + +"${CC:-cc}" "${cflags[@]}" "${ldflags[@]}" -Wl,--version-script,"${outDir}/version-script" -shared -o tcllibc.so "${outDir}"/*.o "${libs[@]}" +"${OBJCOPY:-objcopy}" --keep-global-symbol Tcllibc_Init tcllibc.so +"${OBJCOPY:-objcopy}" --discard-all tcllibc.so exit 0