MythreyaK wrote:

> I am not familiar with x86_64 baremetal targets. 

To be completely honest, me neither :sweat_smile:. I stumbled across this as I 
was experimenting with clang build to support multiple target triples from the 
same install tree. I got musl working (thanks to @mstorsjo's help!) but faced 
issued with baremetal support. 

> Can you describe your use case and why you need 
> /sysroot/usr/bin/../include/x86_64-unknown-none-elf in the search path list?

I am trying to create a clang sysroot install with support for multiple target 
triples, each with potentially different C library headers (baremetal using 
newlib, `pc-linux` using musl, etc, so they can't be installed to the common 
`usr/include` location). My understanding from experimenting with this so far 
is that this layout (please correct me if I'm wrong)

```
sysroot 
  +--usr 
      +-- include 
            +- <triple>
            +- <triple> 
```

allows clang to support multiple target triples at once.

With the `i386-pc-linux-musl` triple, the search path includes 
`/sysroot/usr/bin/../include/i386-pc-linux-musl` where I can install the musl C 
library headers. So the search paths correctly look for C++, C, and then the 
resource dirs for headers, meaning that the .cfg file for that triple is 
simple. 

For the baremetal target, the triple subdirectory `usr/include/<triple>` is not 
searched, meaning that my previous `i386-unknown-none-elf.cfg` file looked like 
this, 

```
@common.cfg
--target=i386-unknown-none-elf
-isystem=usr/include/c++/v1
-isystem=usr/include/i386-unknown-none-elf/c++/v1
-isystem=usr/include/i386-unknown-none-elf
-L=<CFGDIR>/../../usr/lib/i386-unknown-none-elf
-ffreestanding
-mno-red-zone
```

which felt less than ideal. With this change, clang behaves similarly to the 
musl triple. The include paths in the cfg file can be completely removed and 
feels more uniform with the triple subdirectory layout.  

https://github.com/llvm/llvm-project/pull/183453
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to