Bug#629861: closed by Sylvestre Ledru <sylvestre at debian.org> (Bug#629861: fixed in clang 2.9-4)

Michael Wild themiwi at gmail.com
Tue Jun 14 06:20:05 UTC 2011


On 06/13/2011 11:50 PM, Sylvestre Ledru wrote:
> Le lundi 13 juin 2011 à 17:46 -0400, Anders Kaseorg a écrit :
>> On Mon, 13 Jun 2011, Sylvestre Ledru wrote:
>>> Well, it works for me on my system.
>>
>> Your GccTriple is probably nonempty, because Debian’s gcc-4.5 has not yet 
>> transitioned to the multiarch paths, while Ubuntu’s has.
>>
>>> Interesting. Do you know why upstream is not using this ?
>>
>> I’m really quite mystified.  All of this distro/GCC version detection 
>> nonsense originated in
>>   http://llvm.org/viewvc/llvm-project?view=rev&revision=118382
>> (between clang 2.8 and clang 2.9), and has been fixed up several dozen 
>> times for various distros since then.  You’d think someone would have 
>> noticed that this isn’t a maintainable solution…
> I will drop my one-more-ugly-patch-on-the-top-of-the-hacks and try with
> your suggestion.
> 
> Thanks,
> Sylvestre
> 

I agree that the Linux code in ToolChains.cpp is horrible and
unmaintainable. On the Clang mailing list one of the devs also said that
he would prefer configuration files. Shelling out to ask gcc is also a
bad option. You have to be very careful that you ask it the right thing,
e.g. pass it the right -m32/-m64 flags on i386 and amd64, respectively,
and it gets more complicated on non-Intel architectures.

Since the Clang devs are unlikely to fix 2.9, why not make a patch which
does away with that whole charade of distro-detection and replace it
with a purely Debian-specific implementation? Here the things I think it
would need to do:

- Detect the target gcc-triplet. This can be inferred from the second
argument of the Linux::Linux(const HostInfo&, const llvm::Triple&
Triple) constructor. Perhaps LinuxHostInfo::CreateToolChain() could get
some tweaking too, in order to produce the right triplet upfront (e.g.
i486 instead of i368 on Debian).

- Detect the multiarch-triplet. Similarly to the GCC multiarch patch,
this can be looked up from a table. Essentially that table would map the
gcc-triplet to the corresponding multiarch-triplet (e.g. i486-linux-gnu
to i386-linux-gnu and x86_64-linux-gnu to x86_64-linux-gnu).

- Set up the search paths.

Did I miss something here?

Michael





More information about the Pkg-llvm-team mailing list