Bug 18138 - clang on Mageia v6/Cauldron x86-64 fails with an error on the Hello World program
Summary: clang on Mageia v6/Cauldron x86-64 fails with an error on the Hello World pro...
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: x86_64 Linux
Priority: Normal major
Target Milestone: ---
Assignee: Thierry Vignaud
QA Contact:
URL: https://llvm.org/bugs/show_bug.cgi?id...
Whiteboard:
Keywords: UPSTREAM
: 18202 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-04-06 10:40 CEST by Shlomi Fish
Modified: 2016-09-16 11:02 CEST (History)
5 users (show)

See Also:
Source RPM: clang-3.8.0-9.mga6.src.rpm
CVE:
Status comment:


Attachments
Tentative patch to fix the problem. (939 bytes, patch)
2016-04-24 08:03 CEST, Shlomi Fish
Details | Diff

Description Shlomi Fish 2016-04-06 10:40:34 CEST
Description of problem:

clang on Cauldron fails to compile the hello world program with these errors: 

clang-3.8: error: no such file or directory: 'hello_world.'
clang-3.8: error: no input files

gcc works fine.

Script started on Wed 06 Apr 2016 11:34:51 IDT
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ whci[K[Kich clang
/usr/bin/clang
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ which gcc
/home/shlomif/bin/gcc
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ cat hello_world.c 
/*
 * The canonical Hello World program kept here to avoid code duplication
 *
 * License is the MIT/X11 license - http://opensource.org/licenses/MIT .
 * ( https://en.wikipedia.org/wiki/MIT_License ).
 */
#include <stdio.h>

int main(void)
{
    printf ("%s\n", "Hello World!");

    return 0;
}
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ gcc -o hello.gcc.exe hel 
lo_world.c
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ ./hello.gcc.exe
Hello World!
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ clang hello_world.
clang-3.8: error: no such file or directory: 'hello_world.'
clang-3.8: error: no input files
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ clang hello_world.c
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ exit
exit

Script done on Wed 06 Apr 2016 11:36:38 IDT
Comment 1 Shlomi Fish 2016-04-06 12:42:01 CEST
Some more notes:

1. Rebuilding clang and then llvm and installing all their packages locally did not fix the problem.

2. It also happens in a new UNIX user account:

<<<<<
kdetest@telaviv1:~$ clang /var/tmp/hello_world.c 
/bin/ld: cannot find crtbegin.o: No such file or directory
/bin/ld: cannot find -lgcc
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)
kdetest@telaviv1:~$ cat /var/tmp/hello_world.c
/*
 * The canonical Hello World program kept here to avoid code duplication
 *
 * License is the MIT/X11 license - http://opensource.org/licenses/MIT .
 * ( https://en.wikipedia.org/wiki/MIT_License ).
 */
#include <stdio.h>

int main(void)
{
    printf ("%s\n", "Hello World!");

    return 0;
}
kdetest@telaviv1:~$ 

>>>>>
Comment 2 Rémi Verschelde 2016-04-06 13:42:04 CEST
(In reply to Shlomi Fish from comment #0)
> clang on Cauldron fails to compile the hello world program with these
> errors: 
> 
> clang-3.8: error: no such file or directory: 'hello_world.'
> clang-3.8: error: no input files
> 
> gcc works fine.

I guess you did not meant to report those errors as a bug? Obviously you just mistyped the filename here, and it can't find it.


The other part you reported seems like a valid issue though:

(In reply to Shlomi Fish from comment #1)
> kdetest@telaviv1:~$ clang /var/tmp/hello_world.c 
> /bin/ld: cannot find crtbegin.o: No such file or directory
> /bin/ld: cannot find -lgcc
> clang-3.8: error: linker command failed with exit code 1 (use -v to see
> invocation)
Comment 3 Shlomi Fish 2016-04-06 15:25:17 CEST
(In reply to Rémi Verschelde from comment #2)
> (In reply to Shlomi Fish from comment #0)
> > clang on Cauldron fails to compile the hello world program with these
> > errors: 
> > 
> > clang-3.8: error: no such file or directory: 'hello_world.'
> > clang-3.8: error: no input files
> > 
> > gcc works fine.
> 
> I guess you did not meant to report those errors as a bug? Obviously you
> just mistyped the filename here, and it can't find it.
> 

This was just part of my transcript. There's the right command below it which doesn't work - with different messages, and it is OK. For the record, it is:

<<<<<<<
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ clang hello_world.c 
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)
shlomif@telaviv1:~/progs/C/snippets/shlomif-c-snippets$ 
>>>>>>>>

> 
> The other part you reported seems like a valid issue though:
> 
> (In reply to Shlomi Fish from comment #1)
> > kdetest@telaviv1:~$ clang /var/tmp/hello_world.c 
> > /bin/ld: cannot find crtbegin.o: No such file or directory
> > /bin/ld: cannot find -lgcc
> > clang-3.8: error: linker command failed with exit code 1 (use -v to see
> > invocation)
Comment 4 Shlomi Fish 2016-04-08 18:03:35 CEST
Hi all,

I can reproduce the same problem with LLVM+clang built from source on mageia v6 x86-64 and installed into /opt/llvm using this bash script:

«
#!/bin/bash
b='/opt/llvm'
export PATH="$b/bin:$PATH"
export PKG_CONFIG_PATH="$b/lib64/pkgconfig:$b/lib/pkgconfig:$PKG_CONFIG_PATH"
cmake -DCMAKE_BUILD_TYPE="release" -DCMAKE_INSTALL_PREFIX="$b" "$@"
»

LLVM's "make check" passed and I could not readily find how to run clang's tests. Anyway, it seems to be an upstream problem and I'll report it there.
Marja Van Waes 2016-04-09 17:26:29 CEST

CC: (none) => marja11
Assignee: bugsquad => thierry.vignaud

Comment 5 Shlomi Fish 2016-04-09 18:02:27 CEST
Hi all!

Reported upstream at https://llvm.org/bugs/show_bug.cgi?id=27290 .

URL: (none) => https://llvm.org/bugs/show_bug.cgi?id=27290

Marja Van Waes 2016-04-09 18:19:34 CEST

Keywords: (none) => UPSTREAM
See Also: (none) => https://llvm.org/bugs/show_bug.cgi?id=27290

Comment 6 Rémi Verschelde 2016-04-14 14:46:08 CEST
*** Bug 18202 has been marked as a duplicate of this bug. ***

CC: (none) => jamagallon

Comment 7 Shlomi Fish 2016-04-24 07:33:08 CEST
One workaround I found for this bug today (thanks in part to this stackoverflow thread - http://stackoverflow.com/questions/4160262/clang-linker-problem#4160340 ) is to set these environment variables (e.g: by sourcing the code from Bash):

«
export COMPILER_PATH=/usr/lib/gcc/x86_64-mageia-linux-gnu/5.3.1/
export LIBRARY_PATH="$COMPILER_PATH"
»

after doing that, the Hello World program compiles and I was able to get Freecell Solver to build and pass its tests' suite using /usr/bin/clang.
Comment 8 Shlomi Fish 2016-04-24 08:03:35 CEST
Created attachment 7693 [details]
Tentative patch to fix the problem.
Comment 9 Giuseppe Ghibò 2016-08-31 15:30:08 CEST
Actually this script, posted by Shlomi Fish could work around the problem:

gcc_ver=5.4.0
export COMPILER_PATH=/usr/lib/gcc/x86_64-mageia-linux-gnu/"$gcc_ver"
export CPATH=/usr/include/c++/"$gcc_ver"/:/usr/include/c++/"$gcc_ver"/x86_64-mageia-linux-gnu
export LIBRARY_PATH="$COMPILER_PATH"
export LD=/usr/bin/ld.gold

CC: (none) => ghibomgx

Comment 10 Pascal Terjan 2016-09-08 14:56:06 CEST
lib/Driver/ToolChains.cpp needs to be updated to support mageia, it contains things like:

  static const char *const X86_64Triples[] = {
      "x86_64-linux-gnu",       "x86_64-unknown-linux-gnu",
      "x86_64-pc-linux-gnu",    "x86_64-redhat-linux6E",
      "x86_64-redhat-linux",    "x86_64-suse-linux",
      "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
      "x86_64-slackware-linux", "x86_64-linux-android",
      "x86_64-unknown-linux"};

CC: (none) => pterjan

Comment 12 Pascal Terjan 2016-09-08 17:27:10 CEST
Thanks, we also have armv5tl-mageia-linux-gnueabi and armv7hl-mageia-linux-gnueabi :)
Comment 13 Giuseppe Ghibò 2016-09-16 10:36:00 CEST
Works for me too. I think we can close this bug too, as I was able to compile firefox with current clang/clang++ 3.8.1-3.mga6. Probably worthwhile to submit the patch upstream, if not yet done.

A little off-topic, but for those interested, here is the score list of benchmark (Octane v2) for firefox compiled with clang (have not played much with compilation flags and LTO seems disabled) against gcc (higher score is better):

firefox 48.0.2 with clang/clang++ 3.8.1
compilations flags: -O2 for clang, -O for clang++: 18768

firefox 48.0.2 with gcc 5.4.0
compilation flags: -O2 for gcc, -O2 for g++: 19902

firefox 48.0.2 upstream (they use gcc 4.8.5)
compilation flags: -O3 for g++ with Profile Guided Optimazion enabled: 20901
Comment 14 Thierry Vignaud 2016-09-16 11:02:41 CEST
Closing then

Status: NEW => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.