Repository navigation
Conversation
|
Hi @phr4nky! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Since e0311d0, remap_cwd.py appends `-Wa,--debug-prefix-map=$PWD=.` for every compiler type it wraps. The Clang driver rejects that option ("unsupported argument '--debug-prefix-map=...' to option '-Wa,'"), so every compile of a clang or clang_windows toolchain with `remap_cwd = True` fails. The option is only needed for GCC, which does not pass -ffile-prefix-map on to the GNU assembler for .s/.S/.sx sources. Clang's integrated assembler already honours -ffile-prefix-map. Add it only when compile.bzl passes `--gnu-assembler`, which it does for compiler_type "gcc"; the command GCC runs is unchanged.
62eff4a to
4eff7c9
Compare
|
This pull request has been imported. If you are a Meta employee, you can view this in D134594657. (Because this pull request was imported automatically, there will not be any future comments.) |
|
This pull request has been merged in 354c000. |
Summary:
With `cxx_toolchain(remap_cwd = True)` and a Clang compiler, every compile fails: `prelude/cxx/tools/remap_cwd.py` appends `-Wa,--debug-prefix-map=$PWD=.`, and the Clang driver rejects that option. This PR adds the option only for `compiler_type = "gcc"`, the case it was added for.
## Affected version
Checked at `main` 4b47e1430e and in the latest release, 2026-11-15 (same `remap_cwd.py`, same Clang wrapping in `compile.bzl`). First bad commit: e0311d0a0c ("Enable DWARF debug info for hand-written assembly files"); `remap_cwd.py` from its parent compiles the same input.
## Reproduction
```
printf 'int f(void){return 1;}\n' > a.c
python3 prelude/cxx/tools/remap_cwd.py clang -c a.c -o a.o -g; echo rc=$?
```
## Expected
The compile succeeds and `DW_AT_comp_dir` is `.`, as it was before e0311d0a0c.
## Actual
```
clang: error: unsupported argument '--debug-prefix-map=<cwd>=.' to option '-Wa,'
rc=1
```
Seen with Apple clang 21.0.0 and clang 21.1.8 (also with `--target=x86_64-linux-gnu`), for `.c`, `.s` and `.S` inputs.
## Analysis
`compile.bzl` wraps the compiler in `remap_cwd` for `clang`, `clang_windows`, `clang_cl` and `gcc`. e0311d0a0c added `-Wa,--debug-prefix-map` because GCC does not pass `-ffile-prefix-map` to the GNU assembler. Clang's integrated assembler honours `-ffile-prefix-map`: with only that flag, `DW_AT_comp_dir` is `.` for `.c`, `.s` and `.S` objects.
## Patch
`remap_cwd.py` takes an optional leading `--gnu-assembler` and only then appends `-Wa,--debug-prefix-map`; `compile.bzl` passes it for `compiler_type = "gcc"`. The Apple index-store path calls `remap_cwd` without it.
X-link: meta/buck2#1663
Reviewed By: dtolnay
Differential Revision: D134594657
fbshipit-source-id: 815723edd632a26c3cee7ef50ad7d03965457317
Summary
With
cxx_toolchain(remap_cwd = True)and a Clang compiler, every compile fails:prelude/cxx/tools/remap_cwd.pyappends-Wa,--debug-prefix-map=$PWD=., and the Clang driver rejects that option. This PR adds the option only forcompiler_type = "gcc", the case it was added for.Affected version
Checked at
main4b47e14 and in the latest release, 2026-11-15 (sameremap_cwd.py, same Clang wrapping incompile.bzl). First bad commit: e0311d0 ("Enable DWARF debug info for hand-written assembly files");remap_cwd.pyfrom its parent compiles the same input.Reproduction
Expected
The compile succeeds and
DW_AT_comp_diris., as it was before e0311d0.Actual
Seen with Apple clang 21.0.0 and clang 21.1.8 (also with
--target=x86_64-linux-gnu), for.c,.sand.Sinputs.Analysis
compile.bzlwraps the compiler inremap_cwdforclang,clang_windows,clang_clandgcc. e0311d0 added-Wa,--debug-prefix-mapbecause GCC does not pass-ffile-prefix-mapto the GNU assembler. Clang's integrated assembler honours-ffile-prefix-map: with only that flag,DW_AT_comp_diris.for.c,.sand.Sobjects.Patch
remap_cwd.pytakes an optional leading--gnu-assemblerand only then appends-Wa,--debug-prefix-map;compile.bzlpasses it forcompiler_type = "gcc". The Apple index-store path callsremap_cwdwithout it.Test plan: with the patched script, Apple clang 21.0.0 and clang 21.1.8 compile
.c,.sand.Swith-g(rc 0,DW_AT_comp_diris.in Mach-O and ELF objects); the old script fails on all of them. For GCC, the arguments the script passes to the compiler with--gnu-assemblerare identical to the old script's. Not run: a GCC toolchain build, and a full buck2 build.