LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-04-2013, 10:45 PM   #1
comet.berkeley
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware current
Posts: 148

Rep: Reputation: Disabled
Question llvm - clang broken in current


Clang appears to be broken in the current version of Slackware.

Quote:
#include <stdio.h>

/* Hello */
int main(void)
{
printf("Hello, World!\n");
return 0;
}
$ clang hello.c -o hello
In file included from hello.c:1:
/usr/include/stdio.h:34:11: fatal error: 'stddef.h' file not found
# include <stddef.h>
^
1 error generated.


clang works fine in Slackware 14.0 stable.

This looks similar to a bug reported in Debian last spring:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=671913
 
Old 01-05-2013, 04:47 AM   #2
TommyC7
Member
 
Registered: Mar 2012
Distribution: Slackware, CentOS, OpenBSD, FreeBSD
Posts: 436

Rep: Reputation: Disabled
Yep, it worked before the gcc and other upgrades though. Although, even then clang wouldn't compile C++ code either (and llvm/clang still gets similar errors when attempting to compile C++ code):
Code:
#include <iostream>

using namespace std;

int main()
{
cout << "Hello World!\n";

return 0;
}
I think Pat and crew know about this, though. ponce or pprkut (curse your similar names!) on IRC said this was found just after 14.0 came out (C++ code not compiling that is).

Clang 3.2 came out 20 days ago (to the date of this post), so I think if we wait patiently we'll get it in -current and perhaps it'll fix the problems (I read somewhere that a newer clang/llvm will fix it).

Last edited by TommyC7; 01-05-2013 at 04:48 AM.
 
Old 01-05-2013, 02:53 PM   #3
comet.berkeley
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware current
Posts: 148

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TommyC7 View Post
Yep, it worked before the gcc and other upgrades though. Although, even then clang wouldn't compile C++ code either (and llvm/clang still gets similar errors when attempting to compile C++ code):
Code:
#include <iostream>

using namespace std;

int main()
{
cout << "Hello World!\n";

return 0;
}
I think Pat and crew know about this, though. ponce or pprkut (curse your similar names!) on IRC said this was found just after 14.0 came out (C++ code not compiling that is).

Clang 3.2 came out 20 days ago (to the date of this post), so I think if we wait patiently we'll get it in -current and perhaps it'll fix the problems (I read somewhere that a newer clang/llvm will fix it).
After further research on google: clang "fatal error:" "file not found"

It looks like all different versions of clang on all different platforms can fail with this error.

And after using the "-v" option of clang, I found the problem.

$ clang -v hello.c
clang version 3.0 (tags/RELEASE_30/final)
Target: x86_64-slackware-linux-gnu
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-slackware-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name hello.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.22.52.0.2.20120424 -momit-leaf-frame-pointer -v -resource-dir /usr/bin/../lib/clang/3.0 -fmodule-cache-path /var/tmp/clang-module-cache -cxx-isystem /usr/lib64/qt/include -cxx-isystem /usr/lib64/qt/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.0/include -internal-externc-isystem /usr/include/ -internal-externc-isystem /usr/lib64/gcc/x86_64-slackware-linux/4.7.1//include/ -internal-externc-isystem /usr/lib64/gcc/x86_64-slackware-linux/4.7.1//include-fixed/ -ferror-limit 19 -fmessage-length 121 -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/hello-YoK0jd.o -x c hello.c
clang -cc1 version 3.0 based upon llvm 3.0 hosted on x86_64-slackware-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/clang/3.0/include"
ignoring nonexistent directory "/usr/lib64/gcc/x86_64-slackware-linux/4.7.1//include/"
ignoring nonexistent directory "/usr/lib64/gcc/x86_64-slackware-linux/4.7.1//include-fixed/"

#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/include/
End of search list.
In file included from hello.c:1:
/usr/include/stdio.h:34:11: fatal error: 'stddef.h' file not found
# include <stddef.h>
^
1 error generated.

The current installation of clang is dependent on gcc 4.7.1, but Slackware current uses gcc 4.7.2

This means that clang must be re-built every time that gcc changes and I suspect that this is true for g++ and any other compiler that clang might use.

Last edited by comet.berkeley; 01-05-2013 at 03:03 PM. Reason: grammar
 
Old 01-06-2013, 07:33 AM   #4
mats_b_tegner
Member
 
Registered: Nov 2009
Location: Gothenburg, Sweden
Distribution: Slackware64
Posts: 140

Rep: Reputation: 47
I downloaded llvm/clang 3.2 and compiled them on -current using the SlackBuild-script from /source/d/llvm and the Hello World example works using clang and clang++. Another package that also needs to be rebuilt is libtool.
 
Old 01-06-2013, 09:34 AM   #5
GazL
Senior Member
 
Registered: May 2008
Posts: 3,365

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Looks like a side-effect of the slackbuild doing this:

Code:
CINC="/usr/include/"
GCCDIR=/usr/lib$LIBDIRSUFFIX/gcc/$ARCH-slackware-linux*/*/
CINC="$CINC:$(echo ${GCCDIR})/include/"
CINC="$CINC:$(echo ${GCCDIR})/include-fixed/"

./configure \
  --with-c-include-dirs=$CINC \

Wondering why clang needs gcc specific includes anyway. Seems kind of odd.
 
Old 01-10-2013, 04:57 AM   #6
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 2,546

Rep: Reputation: 419Reputation: 419Reputation: 419Reputation: 419Reputation: 419
llvm is now included in -Current
 
Old 01-10-2013, 05:12 AM   #7
GazL
Senior Member
 
Registered: May 2008
Posts: 3,365

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Thanks for the heads up willy, my mirror hasn't updated yet so I wasn't aware of that.

I notice that the 'current' slackbuild still references those gcc include directories, and there will still be this odd version dependency between gcc and clang because of that. Does anyone know why they are included on that -with-c-include-dirs config option?
 
Old 01-11-2013, 01:46 AM   #8
imprazaguy
LQ Newbie
 
Registered: Sep 2009
Distribution: Slackware64 13.37
Posts: 4

Rep: Reputation: 7
It's because llvm/clang's vanilla source has some bugs that can't find correct include directory.

I have written a slackbuild script for llvm 3.1. (The newest for now is 3.2. I haven't tested yet.)
https://bitbucket.org/imprazaguy/sla...lvm?at=default
It uses some patches to fix the path problem.

"with-c-include-dirs" is a simple solution but is not correct.
It is not correct because clang should use its specific headers, not gcc's.
I remember when I modified original slackbuild to compile llvm 3.1. I built with compiler-rt and problems occurred because it used gcc specific include headers, not clang's.

I think the correct way is to add some patches to fix the path problem.

Last edited by imprazaguy; 01-11-2013 at 01:48 AM.
 
2 members found this post helpful.
Old 01-11-2013, 03:56 AM   #9
GazL
Senior Member
 
Registered: May 2008
Posts: 3,365

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Yes, looks like it needs some attention. Thanks for the link to your build/patches.
 
Old 01-13-2013, 02:01 AM   #10
comet.berkeley
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware current
Posts: 148

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by willysr View Post
llvm is now included in -Current
Yes, since the update of current on Jan 10, clang now compiles "hello world" correctly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: LLVM's Clang Is Almost Good Enough For Debian LXer Syndicated Linux News 0 03-06-2012 10:00 PM
Installation of Just Clang/LLVM Documentation? haziz Debian 1 01-08-2012 04:18 AM
Clang/LLVM Install Within Slackware? haziz Slackware 8 01-03-2012 03:46 AM
LXer: LLVM/Clang On The ARMv7 PandaBoard ES LXer Syndicated Linux News 0 12-29-2011 09:50 PM
LXer: LLVM project's 2.7 release out with a Clang LXer Syndicated Linux News 0 04-28-2010 09:31 PM


All times are GMT -5. The time now is 11:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration