This is an archive of the discontinued LLVM Phabricator instance.

build: add a heuristic to determine the C++ ABI
AbandonedPublic

Authored by compnerd on Jan 5 2017, 3:21 PM.

Details

Summary

We need to have a more principled method to detect the C++ ABI we are
targeting. Add a heuristic to determine that and pass it to the build.

Diff Detail

Repository
rL LLVM

Event Timeline

compnerd updated this revision to Diff 83314.Jan 5 2017, 3:21 PM
compnerd retitled this revision from to build: add a heuristic to determine the C++ ABI.
compnerd updated this object.
compnerd set the repository for this revision to rL LLVM.
compnerd added subscribers: cfe-commits, rnk.

Why isn't this equivalent to _MSC_VER ?

smeenai edited edge metadata.Jan 5 2017, 4:27 PM

Why isn't this equivalent to _MSC_VER ?

You can have scenarios where you're targeting the Itanium ABI but still have _MSC_VER defined, e.g.

% clang -target i686-windows-itanium -fmsc-version=1900 -E -dM - < /dev/null | grep _MSC_VER
#define _MSC_VER 1900
rnk added a comment.Jan 5 2017, 5:02 PM

Why isn't this equivalent to _MSC_VER ?

It might also be nice for clang to define some macro to indicate which C++ ABI is in use.

All that said, I think it makes sense to encode this in libc++ include/__config_site because you don't want people to build libc++ for the MS ABI and then try to use it with a mingw triple. It'd be nice if we could diagnose that at compile time instead of link time.

@rnk happy to add such a macro. Would __cpp_abi_itanium and __cpp_abi_microsoft be palatable?

This actually does get encoded into __config albeit in a round-about way. The __config_site gets concatenated with __config into __generated_config which is installed as __config.

EricWF edited edge metadata.Jan 6 2017, 11:34 AM

@rnk happy to add such a macro. Would __cpp_abi_itanium and __cpp_abi_microsoft be palatable?

I would love these macros. I would prefer if the stock __config worked for all but the rarest of configurations.

compnerd abandoned this revision.Jan 7 2017, 1:42 PM

We have a temporary workaround while a proper macro is considered by SD-6.