[llvm-bugs] [Bug 30403] New: -fno-builtin gets lost on the way to Gold plugin

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 15 12:54:46 PDT 2016


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

            Bug ID: 30403
           Summary: -fno-builtin gets lost on the way to Gold plugin
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: krasin at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17272
  --> https://llvm.org/bugs/attachment.cgi?id=17272&action=edit
libc_free.c

Consider the following program (also attached):

__attribute__((noinline))
void touch(char *random_buffer) {
  random_buffer[0] = 17;
}

void _start(void* info) {
  char buf[512];
  int i;
  for (i = 0; i < 512; ++i) {
    buf[i] = 0;
  }
  touch(buf);
}

Let's build it w/o libc and with ThinLTO:

$ clang -flto=thin -fno-builtin -c libc_free.c -o libc_free.o
$ clang -nostdlib -Wl,--no-undefined -fuse-ld=gold -flto=thin -o libc_free
libc_free.o
/tmp/lto-llvm-e2379d.o:libc_free.o:function _start: error: undefined reference
to 'memset'
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)

What happens here is the first command line forgets to attach nobuiltin
attribute to _start, and the second command line recognizes memset in the loop
and then fails by not being able to find the symbol.

With full LTO the command line succeeds, most likely (I have not looked
closely) due to some optimization pass disabled and therefore not triggering
the issue. Still, the blame is on the Clang frontend.

-- 
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/20160915/7115337c/attachment-0001.html>


More information about the llvm-bugs mailing list