<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62887>62887</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            16.0.5: libc++/libc++abi tests using shared libraries and exceptions fail on ARM
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++,
            libc++abi,
            backend:ARM
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          luporl
      </td>
    </tr>
</table>

<pre>
    When testing libc++/libc++abi on ARMv7, several failures occur in the tests using the shared config. The failures are all similar to the one below:

```
********************
FAIL: llvm-libc++-shared.cfg.in :: std/strings/string.conversions/stod.pass.cpp (10 of 87800)
******************** TEST 'llvm-libc++-shared.cfg.in :: std/strings/string.conversions/stod.pass.cpp' FAILED ********************
Script:
--
: 'COMPILED WITH'; /home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/./bin/clang++ /home/leandro.lupori/git/llvm16-armv7/llvm-project/libcxx/test/std/strings/string.conversions/stod.pass.cpp --target=armv7l-unknown-linux-gnueabihf -nostdinc++ -I /home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/include/c++/v1 -I /home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/include/c++/v1 -I /home/leandro.lupori/git/llvm16-armv7/final/llvm-project/libcxx/test/support -std=c++2b -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_DISABLE_AVAILABILITY -Werror=thread-safety -Wuser-defined-warnings  -lc++experimental -nostdlib++ -L /home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/./lib -Wl,-rpath,/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/./lib -lc++ -pthread -o /home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/runtimes/runtimes-bins/test/std/strings/string.conversions/Output/stod.pass.cpp.dir/t.tmp.exe
: 'EXECUTED AS';  "/usr/bin/python3.10" /home/leandro.lupori/git/llvm16-armv7/final/llvm-project/libcxx/test/../utils/run.py --execdir /home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/runtimes/runtimes-bins/test/std/strings/string.conversions/Output/stod.pass.cpp.dir -- /home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/runtimes/runtimes-bins/test/std/strings/string.conversions/Output/stod.pass.cpp.dir/t.tmp.exe
--
Exit Code: 245

Command Output (stdout):
--
$ ":" "COMPILED WITH"
note: command had no output on stdout or stderr
$ "/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/./bin/clang++" "/home/leandro.lupori/git/llvm16-armv7/llvm-project/libcxx/test/std/strings/string.conversions/stod.pass.cpp" "--target=armv7l-unknown-linux-gnueabihf" "-nostdinc++" "-I" "/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/include/c++/v1" "-I" "/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/include/c++/v1" "-I" "/home/leandro.lupori/git/llvm16-armv7/final/llvm-project/libcxx/test/support" "-std=c++2b" "-Werror" "-Wall" "-Wctad-maybe-unsupported" "-Wextra" "-Wshadow" "-Wundef" "-Wno-unused-command-line-argument" "-Wno-attributes" "-Wno-pessimizing-move" "-Wno-c++11-extensions" "-Wno-noexcept-type" "-Wno-atomic-alignment" "-Wno-user-defined-literals" "-Wno-tautological-compare" "-Wsign-compare" "-Wunused-variable" "-Wunused-parameter" "-Wunreachable-code" "-Wno-unused-local-typedef" "-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER" "-D_LIBCPP_ENABLE_EXPERIMENTAL" "-D_LIBCPP_DISABLE_AVAILABILITY" "-Werror=thread-safety" "-Wuser-defined-warnings" "-lc++experimental" "-nostdlib++" "-L" "/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/./lib" "-Wl,-rpath,/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/./lib" "-lc++" "-pthread" "-o" "/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/runtimes/runtimes-bins/test/std/strings/string.conversions/Output/stod.pass.cpp.dir/t.tmp.exe"
note: command had no output on stdout or stderr
$ ":" "EXECUTED AS"
note: command had no output on stdout or stderr
$ "/usr/bin/python3.10" "/home/leandro.lupori/git/llvm16-armv7/final/llvm-project/libcxx/test/../utils/run.py" "--execdir" "/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/runtimes/runtimes-bins/test/std/strings/string.conversions/Output/stod.pass.cpp.dir" "--" "/home/leandro.lupori/git/llvm16-armv7/final/Phase3/Release/llvmCore-16.0.5-final.obj/runtimes/runtimes-bins/test/std/strings/string.conversions/Output/stod.pass.cpp.dir/t.tmp.exe"
note: command had no output on stdout or stderr
error: command failed with exit status: 245
```

LLVM, from branch release/16.x, was built and tested using test-release.sh:
```
llvm-project/llvm/utils/release/test-release.sh -triple armv7a-unknown-linux-gnueabihf \
    -release 16.0.5 -final -no-checkout -no-openmp -no-mlir -no-flang -use-ninja \
 -configure-flags '-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DLLVM_LIT_ARGS=-v -DCOMPILER_RT_USE_LLVM_UNWINDER=ON -DCMAKE_C_COMPILER_TARGET=armv7a-linux-gnueabihf'
```

Debugging the test program, it was noticed that it crashes when an exception is being handled.
Besides that, the unwind symbols are being resolved to those of libgcc_s instead of libunwind, even though LLVM was configured with COMPILER_RT_USE_LLVM_UNWINDER=ON.

The patch below fixes the issue, but I'm not sure if this is the right way to fix it. It's also probably incomplete, as I guess the addition of `-lunwind` should be conditional to COMPILER_RT_USE_LLVM_UNWINDER or maybe other setting.

```
diff --git a/libcxx/test/configs/llvm-libc++-shared.cfg.in b/libcxx/test/configs/llvm-libc++-shared.cfg.in
index 7228c7e8d467..9fba9bbfc6b2 100644
--- a/libcxx/test/configs/llvm-libc++-shared.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared.cfg.in
@@ -10,7 +10,7 @@ config.substitutions.append(('%{compile_flags}',
     '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support'
 ))
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib++ -L %{lib} -Wl,-rpath,%{lib} -lc++ -pthread'
+    '-nostdlib++ -L %{lib} -Wl,-rpath,%{lib} -lc++ -lunwind -pthread'
 ))
 config.substitutions.append(('%{exec}',
     '%{executor} --execdir %T -- '
diff --git a/libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in b/libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in
index f742574e6fbb..1dfd7ca1d514 100644
--- a/libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in
+++ b/libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in
@@ -10,7 +10,7 @@ config.substitutions.append(('%{compile_flags}',
     '-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
 ))
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib++ -L %{lib} -Wl,-rpath,%{lib} -lc++ -lc++abi -pthread'
+    '-nostdlib++ -L %{lib} -Wl,-rpath,%{lib} -lc++ -lc++abi -lunwind -pthread'
 ))
 config.substitutions.append(('%{exec}',
     '%{executor} --execdir %T -- '
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWltv4yrX_jXuzRKWQ4696EWaw97Rlx7UprszVxG2l21mCFiA0_T79a-wncRJM51DZzp7jxRFBhbr8ACLB2xmDE8l4oXXvfS64zNW2EzpC1HkSouzUMXPF48ZSrBoLJcpCB5GHr0sf9N9gYUclITh3dW679ERGFyjZgISxkWh0YCKokIDl2AzLJUZKIxT6MomYxpjiJRMeOrDIsN9R6YRmBBg-IoLpsGqsouSCCEK9eS1h14w9oLtfy-of1WRvuFXapgOZ3OvPQQh1iuyD5hUPvtRkvpcgvOiPQRjY49OjdVcpmb35EdKrlEbrmRVqWI_Z8b4UZ6DRwetAFQCg_4gCDx6_nbHYTG5X4BH-7_IZ4_2wcEyGcPb8b2PNM_tbhQJqeNvD10Eo5ur29LQ42zxt0f7XvsSPDrN1Ard_EMmY638crZyj05Tbl21WK9aPcL0yk3GacIlEx6d3mbMYNuj0zsUyAzWkiOlkbR6fuB3SSnqq_CTR6e-R6chlx6dRoLJtILwu42XQ5Br9QkjW6-YzcajU7cESly_e8IQYplO0XrtcWlEkEJ-lupJEsFlsSGpLJCFPEuASGVszGU9_EBm74Udl5EoYie1Txbr1n_aga8NZJHnSlsgbkTb49oqDYE8otZKA3l0WYw8RpbFZMWeQySFrHth7MQ2VjMgjyZjsXoC8ljIGBMgj1KRQhYGYxKp1YrJ2A00EqbTYoXSVhLMWs3DwqKpyjkalzH_n8uUrNQaq9rarVaL4MaiLCdY1SIVbiLMLbHPOW5VqhWPCBM8lXtDhUFNYky4ROeIdWm-1mFZYZVQKY-YcL7mLneTR7fBNIp1LGumOQtFoyZnmq3Qoi6rNLIocwIkUjEewCCUM-AcLQEaL-ezy9Ht7fLv4f3y-mZ5ezf862q4vP94v5hcLf-eDMeTu4bU5Hp4OZ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