https://bugs.llvm.org/show_bug.cgi?id=51509

            Bug ID: 51509
           Summary: Link error with __attribute__((target)) and inline
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Created attachment 25149
  --> https://bugs.llvm.org/attachment.cgi?id=25149&action=edit
Reproducer

The following code (also in bug.C) fails to link:

#include <iostream>
#include <string>

__attribute__((target("default"))) inline std::string target() { return
"default"; }

int main() {
  std::cout << target() << std::endl;
}

bash> clang++ bug.C -o bug
Undefined symbols for architecture x86_64:
  "std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::basic_string<std::__1::nullptr_t>(char const*)",
referenced from:
      target() in bug-b35498.o
ld: symbol(s) not found for architecture x86_64

If either removing the inline keyword or the __attribute__((target("default"))
it links again.

clang++ -v
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I get the same problem on a Linux machine with a clang 12.0 that I built from
sources and which is using libstdc++ from gcc 11.1 via the --gcc-toolchain
switch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to