[llvm-dev] Restrict global constructors to base ISA
Friedman, Eli via llvm-dev
llvm-dev at lists.llvm.org
Wed Dec 5 12:24:08 PST 2018
On 12/5/2018 3:28 AM, Jeffrey Walton wrote:
> On Mon, Dec 3, 2018 at 2:30 PM Friedman, Eli <efriedma at codeaurora.org> wrote:
>> ...
>>> How do we tell Clang to use the base ISA for global constructors?
>> There isn't any way to specifically restrict the ISA for global
>> constructors/inline functions/etc. The inverse works, though: you can
>> specify the base ISA for the whole file, then mark specific functions
>> using __attribute__((target("avx2"))).
> It looks like this is becoming more of a problem as CPU advance and
> folks try to add multiple implementations.
> https://stackoverflow.com/a/24136523/608639 .
>
> The problem with attributes is, it is too new. They did not appear
> until GCC 5 for x86_64, and GCC 6 for ARM. They also seem to be
> missing for some platforms, like MIPS and PowerPC. We support back to
> GCC 3 and Visual Studio 2002 for our sources so we need something more
> more available.
Besides the target attribute, there are basically only two possibilities:
1. Modify the source code so the file in question doesn't have any
global constructors/functions with weak linkage/etc.. (The simplest way
to ensure you aren't using any problematic constructs is to use C
instead of C++.)
2. Put the code into a separate library and dynamically load it with
dlopen().
-Eli
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
More information about the llvm-dev
mailing list