LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 25510 - __builtin_cpu_supports("sse3") compiles, but fails when linking.
Summary: __builtin_cpu_supports("sse3") compiles, but fails when linking.
Status: RESOLVED FIXED
Alias: None
Product: compiler-rt
Classification: Unclassified
Component: compiler-rt (show other bugs)
Version: unspecified
Hardware: Macintosh MacOS X
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-12 15:18 PST by K. Adam Christensen
Modified: 2016-07-18 16:39 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description K. Adam Christensen 2015-11-12 15:18:25 PST
I am compiling on OSX 10.11 with clang-3.7 from macports. Here's some sample code to demonstrate the problem:

    #include <stdio.h>
    #include <stdlib.h>

    int main() {
    #if(__has_builtin(__builtin_cpu_supports)) && defined(__x86_64__)
      printf("__builtin_cpu_supports: %d\n", __builtin_cpu_supports("sse3"));
    #else
      printf("__builtin_cpu_cupports not available\n");
    #endif
      return EXIT_SUCCESS;
    }

If I compile with clang-3.7 or clang-3.8 (both which claim to have the builtin cpu supports), everything works. However, during linking, I get the following:

    Undefined symbols for architecture x86_64:
      "___cpu_model", referenced from:
          _dt_init in darktable.c.o
    ld: symbol(s) not found for architecture x86_64

With earlier versions of clang, I see the else clause.

I have also seen this in the wild where this problem exists for FreeBSD as well. https://github.com/darktable-org/darktable/commit/081bc5823870918160fdd93d0157d56263add7d5.
Comment 1 Eric Christopher 2015-11-12 15:22:41 PST
Yes, the required runtime support isn't currently in compiler-rt, it only exists in libgcc right now for the appropriate platforms.

It shouldn't take much to do it though.
Comment 2 Sean Silva 2016-06-26 17:57:01 PDT
Moving to more specific "MachO" LLD component (instead of generic "All Bugs").
Comment 3 Eric Christopher 2016-06-29 14:33:47 PDT
Moving to the compiler-rt component as that's where the support needs to reside.
Comment 4 Alina Sbirlea 2016-07-18 16:39:15 PDT
This should be resolved by r275484.