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,7 +10,13 @@ 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': @@ -19,12 +25,20 @@ 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)