diff --git a/app-tools/Makefile b/app-tools/Makefile index beb39b817..3e1e0c033 100644 --- a/app-tools/Makefile +++ b/app-tools/Makefile @@ -83,6 +83,7 @@ ${TOOLOBJ}/${2}: ${1} Makefile ${TOOLOBJ} -e 's#!PLATFORM!#$(PLATFORM)#g;' \ -e 's#!CPPFLAGS!#$(BUILDRUMP_TOOL_CPPFLAGS)#g;' \ -e 's#!CFLAGS!#$(BUILDRUMP_TOOL_CFLAGS)#g;' \ + -e 's#!GCCNOPIE!#$(GCCNOPIE)#g;' \ -e 's#!CXXFLAGS!#$(BUILDRUMP_TOOL_CXXFLAGS)#g;' \ -e 's#!LDFLAGS_BAKE!#$(LDFLAGS_BAKE)#g;' chmod 755 $$@ diff --git a/app-tools/cc.in b/app-tools/cc.in index 158879e5b..97b359ffb 100644 --- a/app-tools/cc.in +++ b/app-tools/cc.in @@ -89,10 +89,6 @@ compile) ;; ferment) meta1="$(${PRMETA} "${OUTFILE}" 2>/dev/null)" - nopieoption= - if [ -z "`echo 'int p=1;' | ${CC} -no-pie -S -o /dev/null -x c - 2>&1`" ]; then - nopieoption=-no-pie - fi # Link the real (from user's PoV) output file as a relocatable object, # with no rump components. '-u main' is necessary to pull in main if the @@ -100,7 +96,7 @@ ferment) ${CC} ${CFLAGS} -no-integrated-cpp \ --sysroot !DESTDIR!/rumprun-!MACHINE_GNU_ARCH! \ -specs=!DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib/specs-compile_or_ferment \ - ${nopieoption} -Wl,-r -Wl,-u,main \ + !GCCNOPIE! -Wl,-r -Wl,-u,main \ "$@" !DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/share/!TOOLTUPLE!-recipe.s ${EXTRALIBS} || die # If the presumed output file did not change, and the compiler diff --git a/app-tools/cookfs.in b/app-tools/cookfs.in index 60bc5b43f..ea7387480 100644 --- a/app-tools/cookfs.in +++ b/app-tools/cookfs.in @@ -155,11 +155,6 @@ setfilevars () rf=_rumpfs_f${fn} } -nopieoption= -if [ -z "`echo 'int p=1;' | ${RUMPRUN_COOKFS_CC} -no-pie -S -o /dev/null -x c - 2>&1`" ]; then - nopieoption=-no-pie -fi - processonefile () { @@ -169,7 +164,7 @@ processonefile () ln -sf -- "${fabs}" ${LINKPATH} ${RUMPRUN_COOKFS_CC} !CFLAGS! !CPPFLAGS! -nostdlib \ - ${nopieoption} -Wl,-r,-b,binary -o ${TMPDIR}/d${fn}.o ${LINKPATH} + !GCCNOPIE! -Wl,-r,-b,binary -o ${TMPDIR}/d${fn}.o ${LINKPATH} ${RUMPRUN_COOKFS_OBJCOPY} \ --redefine-sym ${LINKPATH_BIN}_start=${rf}_start \ @@ -238,7 +233,7 @@ exec 1>&3 3>&- unset IFS ${RUMPRUN_COOKFS_CC} !CFLAGS! !CPPFLAGS! -I${RUMPRUN_COOKFS_INCDIR} \ - -nostdlib ${nopieoption} -Wl,-r -o ${TMPDIR}/fin.o ${TMPDIR}/d*.o ${TMPDIR}/constr.c + -nostdlib !GCCNOPIE! -Wl,-r -o ${TMPDIR}/fin.o ${TMPDIR}/d*.o ${TMPDIR}/constr.c ${RUMPRUN_COOKFS_OBJCOPY} ${LSYM} ${TMPDIR}/fin.o ${OUTFILE} totsize=$(${RUMPRUN_COOKFS_SIZE} ${OUTFILE} | awk 'NR == 2{print $4}') diff --git a/app-tools/rumprun-bake.in b/app-tools/rumprun-bake.in index cd69ac4f3..069a73805 100644 --- a/app-tools/rumprun-bake.in +++ b/app-tools/rumprun-bake.in @@ -397,13 +397,9 @@ done MACHINE_GNU_ARCH=${RUMPBAKE_TUPLE%%-*} -nopieoption= -if [ -z "`echo 'int p=1;' | ${RUMPBAKE_BACKINGCC} -no-pie -S -o /dev/null -x c - 2>&1`" ]; then - nopieoption=-no-pie -fi # Final link using cc to produce the unikernel image. -${runcmd} ${RUMPBAKE_BACKINGCC} ${RUMPBAKE_CFLAGS} ${nopieoption} \ +${runcmd} ${RUMPBAKE_BACKINGCC} ${RUMPBAKE_CFLAGS} !GCCNOPIE! \ --sysroot ${RUMPBAKE_TOOLDIR}/rumprun-${MACHINE_GNU_ARCH} \ -specs=${RUMPBAKE_TOOLDIR}/rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/specs-bake \ -o ${OUTPUT} ${allobjs} \ diff --git a/build-rr.sh b/build-rr.sh index e361c327d..7c4d67ff1 100755 --- a/build-rr.sh +++ b/build-rr.sh @@ -340,6 +340,14 @@ checktools () echo '>>' sleep ${delay} fi + + # Check for if compiler supports -no-pie and set nopieoption + GCCNOPIE= + if [ -z "`echo 'int p=1;' | $CC -no-pie -S -o /dev/null -x c - 2>&1`" ]; then + GCCNOPIE=-no-pie + fi + export GCCNOPIE + } buildrump ()