ref: b286be8fc1cbdaf0e2857d62a2269e09fdd4701d
parent: 9765e95b59e0b020c32609b69cf573c597857abf
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Oct 2 17:44:23 EDT 2021
tests/libc: Fix cc.sh for OpenBSD The option to disable pie linking must be passed to the linker itself, and the option to disable pie code generation is a different option.
--- a/tests/libc/execute/cc.sh
+++ b/tests/libc/execute/cc.sh
@@ -41,13 +41,16 @@
cc=${CROSS_COMPILE}gcc
ld=${CROSS_COMPILE}ld
-includes="-nostdinc -I$inc -I$arch_inc -I$sys_inc"
-flags="-std=c99 -g -w -fno-stack-protector --freestanding -static"
-
if ${cc} -nopie 2>&1 | grep unrecogn >/dev/null
then
pie=-no-pie
+else
+ pie=-nopie
fi
-${cc} $flags $pie $includes -c $1
-${ld} -g -z nodefaultlib -static -L$lib $obj $crt -lc -lcrt -o $out
+includes="-nostdinc -I$inc -I$arch_inc -I$sys_inc"
+cflags="-std=c99 -g -w -fno-pie -fno-stack-protector -ffreestanding -static"
+ldflags="-g -z nodefaultlib -static $pie -L$lib"
+
+$cc $cflags $includes -c $1
+$ld $ldflags $obj $crt -lc -lcrt -o $out