From: Waldemar Kozaczuk <[email protected]> Committer: Nadav Har'El <[email protected]> Branch: master
scripts: expand %(libgcc_s_dir) when generating usr.manifest The manifest skeleton files like usr.manifest.skel have an entry for libgcc_s_dir looking like this: /usr/lib/libgcc_s.so.1: %(libgcc_s_dir)s/libgcc_s.so.1 This actually gets expanded quite late during the build process by upload_manifest.py. The unfortunate consequence of this is that loader.py used during debugging which reads usr.manifest does not have any logic to load libgcc_s.so.1. And this makes stack traces look useless in those cases that involve libgcc_s.so.1. So this patch slightly changes the scripts/build and scripts/module.py to expand %(libgcc_s_dir) when writing to build/release/usr.manifest. As a result of this the stack trace of the crash I have been working on looks much more reasonable: (gdb) bt '#0 0x00000000403047c2 in processor::cli_hlt () at arch/x64/processor.hh:247 #1 arch::halt_no_interrupts () at arch/x64/arch.hh:48 #2 osv::halt () at arch/x64/power.cc:29 #3 0x0000000040239504 in abort (fmt=fmt@entry=0x405b1e93 "Aborted\n") at runtime.cc:142 #4 0x0000000040202e80 in abort () at runtime.cc:106 #5 0x000010000002b6b6 in ?? () #6 0x000010000003f5cb in _Unwind_Resume () #7 0x0000100000062daa in ?? () #8 0x0000100000075b5c in boost::execution_monitor::vexecute(boost::function<void ()> const&) () #9 0x000010000007f0a9 in boost::unit_test::framework::init(bool (*)(), int, char**) () #10 0x000010000009254d in boost::unit_test::unit_test_main(bool (*)(), int, char**) () #11 0x000000004039d021 in osv::application::run_main (this=0xffffa00000bd8c10) at core/app.cc:416 #12 0x000000004039d22d in operator() (app=<optimized out>, __closure=0x0) at core/app.cc:236 #13 _FUN () at core/app.cc:238 #14 0x00000000403d089a in operator() (__closure=0xffffa00000d57800) at libc/pthread.cc:116 #15 std::__invoke_impl<void, pthread_private::pthread::pthread(void* (*)(void*), void*, sigset_t, const pthread_private::thread_attr*)::<lambda()>&> (__f=...) at /usr/include/c++/11/bits/invoke.h:61 #16 std::__invoke_r<void, pthread_private::pthread::pthread(void* (*)(void*), void*, sigset_t, const pthread_private::thread_attr*)::<lambda()>&> (__fn=...) at /usr/include/c++/11/bits/invoke.h:154 #17 std::_Function_handler<void(), pthread_private::pthread::pthread(void* (*)(void*), void*, sigset_t, const pthread_private::thread_attr*)::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/11/bits/std_function.h:290 #18 0x000000004036b5ae in sched::thread::main (this=0xffff800000f6a040) at core/sched.cc:1267 #19 sched::thread_main_c (t=0xffff800000f6a040) at arch/x64/arch-switch.hh:325 #20 0x00000000402fda43 in thread_main () at arch/x64/entry.S:116 Signed-off-by: Waldemar Kozaczuk <[email protected]> Message-Id: <[email protected]> --- diff --git a/scripts/build b/scripts/build --- 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 --- a/scripts/module.py +++ b/scripts/module.py @@ -57,12 +57,15 @@ def resolve(m): return re.sub(r'\${(?P<name>.*)}', 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() }) -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/0000000000005b1b7c05deb64bf6%40google.com.
