Jamrules: Force HAIKU_TOP to be relative.

Prior to hrev47631 (2014), HAIKU_TOP was relative when jam was invoked
from the repository root, and not relative when jam was invoked from
any other location, including "generated." In hrev47631, Jamrules
was changed to be as it was before this commit, in order to fix #11101
(Haiku repository creation failed due to the use of relative paths.)

GCC, however, injects the full path passed to the compiler into some
symbols under certain circumstanes (anonymous namespaces, for one),
and so a relative path for more reproducible builds is preferred.
It seems the aforementioned bug is no longer with us, as a full image
build that I did with this change worked just fine.

Note that you will have to run "configure --update" after this
in the case that you usually invoke "jam" from the generated directory,
as the Jamfile configure generated included absolute paths. (The reminder
to do that this diff includes can be removed after some reasonable amount
of time.)
This commit is contained in:
Augustin Cavalier 2018-11-01 20:56:04 -04:00
parent 49783dc8f2
commit 3facc270ea
2 changed files with 25 additions and 7 deletions

View File

@ -1,8 +1,14 @@
# Haiku Jamrules
# Make sure we have an absolute HAIKU_TOP
if $(HAIKU_TOP) = "." {
HAIKU_TOP = $(PWD) ;
# Make sure HAIKU_TOP is relative and either the current or parent directory.
#
# This is done so that invocations to the compiler and other tools, which
# under some circumstances inject the source's path into the generated file,
# are passed relative paths, making builds more reproducible.
if $(HAIKU_TOP) != "." && $(HAIKU_TOP) != ".." {
Exit "You must be in the project root or a \"generated\" directory"
"in order to build Haiku (if you are and are still seeing this"
"message, run \"../configure --update\" to solve the issue.)" ;
}
# Main directories used by the build.

20
configure vendored
View File

@ -208,6 +208,16 @@ real_path()
perl -MCwd=realpath -e'print realpath($ARGV[0]), "\n"' "$1"
}
# relative_to
#
# returns $1 relative to $2
#
relative_to()
{
perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV) . "\n"' \
$1 $2
}
# valid_toolchain
#
# check if a toolchain is valid
@ -1094,13 +1104,15 @@ for targetArch in $HAIKU_PACKAGING_ARCHS; do
done
# Generate a boot strap Jamfile in the output directory.
# Generate a Jamfile in the output directory.
cat << EOF > $outputDir/Jamfile
# automatically generated Jamfile
# -- WARNING --
# This file was AUTOMATICALLY GENERATED by configure, and will be completely
# overwritten the next time configure is run.
HAIKU_TOP = ${sourceDir} ;
HAIKU_OUTPUT_DIR = ${outputDir} ;
HAIKU_TOP = $(relative_to "${sourceDir}" "${outputDir}") ;
HAIKU_OUTPUT_DIR = . ;
include [ FDirName \$(HAIKU_TOP) Jamfile ] ;