[all-commits] [llvm/llvm-project] 9f1d90: [compiler-rt] Fix false positive detection of a ta...

Sergey Kosukhin via All-commits all-commits at lists.llvm.org
Thu Jun 23 05:12:50 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9f1d90bf91570efa124c4a86cd033de374d1049a
      https://github.com/llvm/llvm-project/commit/9f1d90bf91570efa124c4a86cd033de374d1049a
  Author: Sergey Kosukhin <sergey.kosukhin at mpimet.mpg.de>
  Date:   2022-06-23 (Thu, 23 Jun 2022)

  Changed paths:
    M compiler-rt/cmake/Modules/CompilerRTUtils.cmake

  Log Message:
  -----------
  [compiler-rt] Fix false positive detection of a target in compile-only mode

When `compiler-rt` is configured as a runtime, the configure-time target
detection for builtins is done in compile-only mode, which is basically a
test of whether the newly-built `clang` can compile a simple program with
an additional flag (`-m32` and `-m64` in my case). The problem is that on
my Debian system `clang` can compile `int foo(int x, int y) { return x + y; }`
with `-m32` but fails to include `limits.h` (or any other target-specific
header) for the `i386` target:
```
$ /path/to/build/./bin/clang --target=x86_64-unknown-linux-gnu -DVISIBILITY_HIDDEN  -O3 -DNDEBUG  -m32 -std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -MD -MT CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o -MF CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o.d -o CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o -c /path/to/src/compiler-rt/lib/builtins/absvdi2.c
In file included from /path/to/src/compiler-rt/lib/builtins/absvdi2.c:13:
In file included from /path/to/src/compiler-rt/lib/builtins/int_lib.h:93:
In file included from /path/to/build/lib/clang/15.0.0/include/limits.h:21:
In file included from /usr/include/limits.h:25:
/usr/include/features.h:364:12: fatal error: 'sys/cdefs.h' file not found
           ^~~~~~~~~~~~~
1 error generated.
```

This is an attempt to make the target detection more robust: extend the test
program with `#include <limits.h>`.

Differential Revision: https://reviews.llvm.org/D127975




More information about the All-commits mailing list