[PATCH] D53711: [compiler-rt] Workaround using new Clang with an old NDK.

Dan Albert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 25 09:35:26 PDT 2018


danalbert created this revision.
danalbert added a reviewer: eugenis.
Herald added subscribers: Sanitizers, delcypher, dberris, kubamracek, srhines.

We're using an old NDK and a new Clang. New Clangs default to
`-stdlib=libc++` for Android, but those libraries cannot be found by
default with an old NDK. Detect if we need to set `-stdlib=libstdc++`
(can't do so in every case because it will emit a warning in C mode).


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D53711

Files:
  test/sanitizer_common/android_commands/android_compile.py


Index: test/sanitizer_common/android_commands/android_compile.py
===================================================================
--- test/sanitizer_common/android_commands/android_compile.py
+++ test/sanitizer_common/android_commands/android_compile.py
@@ -10,21 +10,35 @@
 output = None
 output_type = 'executable'
 
+# We're using an old NDK and a new Clang. New Clangs default to
+# `-stdlib=libc++` for Android, but those libraries cannot be found by default
+# with an old NDK. Detect if we need to set `-stdlib=libstdc++` (can't do so in
+# every case because it will emit a warning in C mode).
 args = sys.argv[1:]
+is_c = False
+driver_mode_cpp = False
 while args:
     arg = args.pop(0)
     if arg == '-shared':
         output_type = 'shared'
     elif arg == '-c':
         output_type = 'object'
     elif arg == '-o':
         output = args.pop(0)
+    elif arg.endswith('.c'):
+        is_c = True
+    elif arg.startswith('--driver-mode='):
+        driver_mode_cpp = arg.partition('=')[2].endswith('++')
+
+cmd = list(sys.argv[1:])
+if not is_c or driver_mode_cpp:
+    cmd.append('-stdlib=libstdc++')
 
 if output == None:
     print "No output file name!"
     sys.exit(1)
 
-ret = subprocess.call(sys.argv[1:])
+ret = subprocess.call(cmd)
 if ret != 0:
     sys.exit(ret)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53711.171120.patch
Type: text/x-patch
Size: 1299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181025/c02e0e87/attachment.bin>


More information about the llvm-commits mailing list