[llvm-bugs] [Bug 34661] New: Please support #pragma clang target

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 18 12:05:28 PDT 2017


            Bug ID: 34661
           Summary: Please support #pragma clang target
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: myriachan at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

If you want to write an application that automatically uses extended intrinsics
if the processor supports them, you have to compile multiple source files with
differing target command-line options.  This works at a basic level.

There's one major problem, though: if you have inline or template functions in
header files, the compiler will be free to generate code using the extended
features for these functions.  If you're unlucky at link time, the linker will
choose the copy of these functions that use the extended processor features,
causing a crash when they don't exist.

GCC solves this by having pragmas (using the "basic" x86-64 as an example):

#pragma GCC push_options
#pragma GCC target "arch=k8"
#include "MyHeader.h"
#pragma GCC pop_options

Could a #pragma clang target be added for similar purposes?

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170918/5c29b1c5/attachment.html>

More information about the llvm-bugs mailing list