diff --git a/scripts/build b/scripts/build index 38aa70d5bd..fbfe0ae370 100755 --- a/scripts/build +++ b/scripts/build @@ -227,6 +227,21 @@ if [[ ${vars[append_manifest]} == "true" && $modules == "!default" ]]; then modules="empty" fi +CC=gcc +if [[ "$host_arch" == "x86_64" && "$arch" == 'aarch64' ]]; then + CC=${CROSS_PREFIX:-aarch64-linux-gnu-}gcc +fi + +libgcc_s_path=$(${CC} -print-file-name=libgcc_s.so.1) +if [[ "$libgcc_s_path" == "libgcc_s.so.1" ]]; then + cat <<-EOF + Unable to resolve libgcc_s.so.1 using "${CC}". + Looking in build/downloaded_packages/aarch64/gcc/install/lib64 + EOF + libgcc_s_path="build/downloaded_packages/aarch64/gcc/install/lib64/libgcc_s.so.1" +fi +libgcc_s_dir=$(dirname $(readlink -f ${libgcc_s_path})) + # The parentheses start a subshell. Whatever is exported there, doesn't affect the external shell ( # Note: the double-quotes and almost everything in the line below is important to correctly allow spaces @@ -240,7 +255,7 @@ fi esac done # Export the variables we already have. This makes it unnecessary to do "fs__type=$fstype ..." - export fs_type mode OSV_BUILD_PATH + export fs_type mode OSV_BUILD_PATH libgcc_s_dir # Other variables we wanted to rename, I don't know why export ARCH=$arch OSV_BASE=$SRC # Run what we wanted to run. It will inherit everything we exported above. @@ -276,21 +291,6 @@ kernel_end=$(($loader_size+2097151 & ~2097151)) # the case in our old build.mk). cd $OUT -CC=gcc -if [[ "$host_arch" == "x86_64" && "$arch" == 'aarch64' ]]; then - CC=${CROSS_PREFIX:-aarch64-linux-gnu-}gcc -fi - -libgcc_s_path=$(${CC} -print-file-name=libgcc_s.so.1) -if [[ "$libgcc_s_path" == "libgcc_s.so.1" ]]; then - cat <<-EOF - Unable to resolve libgcc_s.so.1 using "${CC}". - Looking in ../downloaded_packages/aarch64/gcc/install/lib64 - EOF - libgcc_s_path="../downloaded_packages/aarch64/gcc/install/lib64/libgcc_s.so.1" -fi -libgcc_s_dir=$(dirname $(readlink -f ${libgcc_s_path})) - if [ "$export" != "none" ]; then export_dir=${vars[export_dir]-$SRC/build/export} "$SRC"/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D libgcc_s_dir="$libgcc_s_dir" diff --git a/scripts/module.py b/scripts/module.py index 8a1a54069c..fec8098793 100755 --- a/scripts/module.py +++ b/scripts/module.py @@ -57,12 +57,15 @@ def resolve(m): return re.sub(r'\${(?P.*)}', resolve, text) -def append_manifest(file_path, dst_file, variables={}): +def append_manifest(file_path, dst_file, libgcc_s_dir, variables={}): with open(file_path) as src_file: for line in src_file: line = line.rstrip() if line != '[manifest]': - dst_file.write(expand(line + '\n', variables)) + expanded_line = expand(line + '\n', variables) + if len(libgcc_s_dir) > 0: + expanded_line = expanded_line.replace('%(libgcc_s_dir)s',libgcc_s_dir) + dst_file.write(expanded_line) def generate_manifests(modules, basic_apps, usrskel='default'): for manifest_type in ["usr", "bootfs"]: @@ -77,14 +80,14 @@ def generate_manifests(modules, basic_apps, usrskel='default'): manifest.write('[manifest]\n') if manifest_skel != 'none': - append_manifest(os.path.join(resolve.get_osv_base(), manifest_skel), manifest) + append_manifest(os.path.join(resolve.get_osv_base(), manifest_skel), manifest, os.getenv('libgcc_s_dir')) for module in modules: module_manifest = os.path.join(module.local_path, manifest_name) if os.path.exists(module_manifest): print("Appending %s to %s" % (module_manifest, manifest_name)) - append_manifest(module_manifest, manifest, variables={ + append_manifest(module_manifest, manifest, os.getenv('libgcc_s_dir'), variables={ 'MODULE_DIR': module.local_path, 'OSV_BASE': resolve.get_osv_base() })