4848fi
4949
5050
51- declare -a rlib_paths
52-
53- # Set the `rlib_paths` global array to a list of all compiler-builtins rlibs
54- update_rlib_paths () {
51+ # Run a command for each `compiler_builtins` rlib file
52+ for_each_rlib () {
5553 if [ -d /builtins-target ]; then
5654 rlib_paths=( /builtins-target/" ${target} " /debug/deps/libcompiler_builtins-* .rlib )
5755 else
5856 rlib_paths=( target/" ${target} " /debug/deps/libcompiler_builtins-* .rlib )
5957 fi
58+
59+ if [ " ${# rlib_paths[@]} " -lt 1 ]; then
60+ echo " rlibs expected but not found"
61+ exit 1
62+ fi
63+
64+ " $@ " " ${rlib_paths[@]} "
6065}
6166
67+
6268# Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
6369update_rlib_paths
64- rm -f " ${rlib_paths[@]} "
70+ for_each_rlib rm -f
6571
6672cargo build -p compiler_builtins --target " $target "
6773cargo build -p compiler_builtins --target " $target " --release
@@ -72,57 +78,64 @@ cargo build -p compiler_builtins --target "$target" --features no-asm --release
7278cargo build -p compiler_builtins --target " $target " --features no-f16-f128
7379cargo build -p compiler_builtins --target " $target " --features no-f16-f128 --release
7480
75- PREFIX=${target// unknown-/ } -
76- case " $target " in
77- armv7-* )
78- PREFIX=arm-linux-gnueabihf-
79- ;;
80- thumb* )
81- PREFIX=arm-none-eabi-
82- ;;
83- * 86* -* )
84- PREFIX=
85- ;;
86- esac
87-
88- NM=$( find " $( rustc --print sysroot) " \( -name llvm-nm -o -name llvm-nm.exe \) )
89- if [ " $NM " = " " ]; then
90- NM=" ${PREFIX} nm"
91- fi
92-
93- # i686-pc-windows-gnu tools have a dependency on some DLLs, so run it with
94- # rustup run to ensure that those are in PATH.
95- TOOLCHAIN=" $( rustup show active-toolchain | sed ' s/ (default)//' ) "
96- if [[ " $TOOLCHAIN " == * i686-pc-windows-gnu ]]; then
97- NM=" rustup run $TOOLCHAIN $NM "
98- fi
81+ symcheck=(cargo run -p symbol-check)
82+ [[ " $target " = " wasm" * ]] && symcheck+=(--features wasm)
9983
10084# Look out for duplicated symbols when we include the compiler-rt (C) implementation
101- update_rlib_paths
102- for rlib in " ${rlib_paths[@]} " ; do
103- set +x
104- echo " ================================================================"
105- echo " checking $rlib for duplicate symbols"
106- echo " ================================================================"
107- set -x
85+ for_each_rlib " ${symcheck[@]} " -- check-duplicates
86+ for_each_rlib rm -f
87+
88+ # PREFIX=${target//unknown-/}-
89+ # case "$target" in
90+ # armv7-*)
91+ # PREFIX=arm-linux-gnueabihf-
92+ # ;;
93+ # thumb*)
94+ # PREFIX=arm-none-eabi-
95+ # ;;
96+ # *86*-*)
97+ # PREFIX=
98+ # ;;
99+ # esac
100+
101+ # NM=$(find "$(rustc --print sysroot)" \( -name llvm-nm -o -name llvm-nm.exe \) )
102+ # if [ "$NM" = "" ]; then
103+ # NM="${PREFIX}nm"
104+ # fi
105+
106+ # # i686-pc-windows-gnu tools have a dependency on some DLLs, so run it with
107+ # # rustup run to ensure that those are in PATH.
108+ # TOOLCHAIN="$(rustup show active-toolchain | sed 's/ (default)//')"
109+ # if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then
110+ # NM="rustup run $TOOLCHAIN $NM"
111+ # fi
112+
113+ # # Look out for duplicated symbols when we include the compiler-rt (C) implementation
114+ # update_rlib_paths
115+ # for rlib in "${rlib_paths[@]}"; do
116+ # set +x
117+ # echo "================================================================"
118+ # echo "checking $rlib for duplicate symbols"
119+ # echo "================================================================"
120+ # set -x
108121
109- duplicates_found=0
110-
111- # NOTE On i586, It's normal that the get_pc_thunk symbol appears several
112- # times so ignore it
113- $NM -g --defined-only " $rlib " 2>&1 |
114- sort |
115- uniq -d |
116- grep -v __x86.get_pc_thunk --quiet |
117- grep ' T __' && duplicates_found=1
118-
119- if [ " $duplicates_found " != 0 ]; then
120- echo " error: found duplicate symbols"
121- exit 1
122- else
123- echo " success; no duplicate symbols found"
124- fi
125- done
122+ # duplicates_found=0
123+
124+ # # NOTE On i586, It's normal that the get_pc_thunk symbol appears several
125+ # # times so ignore it
126+ # $NM -g --defined-only "$rlib" 2>&1 |
127+ # sort |
128+ # uniq -d |
129+ # grep -v __x86.get_pc_thunk --quiet |
130+ # grep 'T __' && duplicates_found=1
131+
132+ # if [ "$duplicates_found" != 0 ]; then
133+ # echo "error: found duplicate symbols"
134+ # exit 1
135+ # else
136+ # echo "success; no duplicate symbols found"
137+ # fi
138+ # done
126139
127140rm -f " ${rlib_paths[@]} "
128141
@@ -143,34 +156,38 @@ build_intrinsics_test --features c --release
143156CARGO_PROFILE_DEV_LTO=true build_intrinsics_test
144157CARGO_PROFILE_RELEASE_LTO=true build_intrinsics_test --release
145158
146- # Ensure no references to any symbols from core
147- update_rlib_paths
148- for rlib in " ${rlib_paths[@]} " ; do
149- set +x
150- echo " ================================================================"
151- echo " checking $rlib for references to core"
152- echo " ================================================================"
153- set -x
154-
155- tmpdir=" ${CARGO_TARGET_DIR:- target} /tmp"
156- test -d " $tmpdir " || mkdir " $tmpdir "
157- defined=" $tmpdir /defined_symbols.txt"
158- undefined=" $tmpdir /defined_symbols.txt"
159-
160- $NM --quiet -U " $rlib " | grep ' T _ZN4core' | awk ' {print $3}' | sort | uniq > " $defined "
161- $NM --quiet -u " $rlib " | grep ' U _ZN4core' | awk ' {print $2}' | sort | uniq > " $undefined "
162- grep_has_results=0
163- grep -v -F -x -f " $defined " " $undefined " && grep_has_results=1
164-
165- if [ " $target " = " powerpc64-unknown-linux-gnu" ]; then
166- echo " FIXME: powerpc64 fails these tests"
167- elif [ " $grep_has_results " != 0 ]; then
168- echo " error: found unexpected references to core"
169- exit 1
170- else
171- echo " success; no references to core found"
172- fi
173- done
159+ for_each_rlib " ${symcheck[@]} " -- check-core-syms
160+
161+ # # Ensure no references to any symbols from core
162+ # update_rlib_paths
163+ # for rlib in "${rlib_paths[@]}"; do
164+ # set +x
165+ # echo "================================================================"
166+ # echo "checking $rlib for references to core"
167+ # echo "================================================================"
168+ # set -x
169+
170+ # tmpdir="${CARGO_TARGET_DIR:-target}/tmp"
171+ # test -d "$tmpdir" || mkdir "$tmpdir"
172+ # defined="$tmpdir/defined_symbols.txt"
173+ # undefined="$tmpdir/defined_symbols.txt"
174+
175+ # $NM --quiet -U "$rlib" | grep 'T _ZN4core' | awk '{print $3}' | sort | uniq > "$defined"
176+ # $NM --quiet -u "$rlib" | grep 'U _ZN4core' | awk '{print $2}' | sort | uniq > "$undefined"
177+ # grep_has_results=0
178+ # grep -v -F -x -f "$defined" "$undefined" && grep_has_results=1
179+
180+ # if [ "$target" = "powerpc64-unknown-linux-gnu" ]; then
181+ # echo "FIXME: powerpc64 fails these tests"
182+ # elif [ "$grep_has_results" != 0 ]; then
183+ # echo "error: found unexpected references to core"
184+ # exit 1
185+ # else
186+ # echo "success; no references to core found"
187+ # fi
188+ # done
189+
190+
174191
175192# Test libm
176193
0 commit comments