Is anyone else seeing a failure in the Sema/typedef-redef.c test?
I'm getting this output:
$ clang -fsyntax-only test/Sema/typedef-redef.c
test/Sema/typedef-redef.c:4:23: error: redefinition of 'size_t'
typedef unsigned long size_t;
^
In file included from test/Sema/typedef-redef.c:3:
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/stddef.h:214:23: error: previous definition is here
typedef __SIZE_TYPE__ size_t;
^
2 diagnostics generated.
Notice that it is including gcc's stddef.h instead of clang's. (btw __SIZE_TYPE__ is defined as 'long unsigned int').
Uhm, so the reason why clang isn't using its own stddef.h is because GetMainExecutable() is returning 'clang' only. It then tries to access the /Headers directory and fails.
This issue has already been reported here for Debian systems, but I confirm this is also an issue with Gentoo stable (glibc 2.6.1).
Uhm, so the reason why clang isn't using its own stddef.h is
because GetMainExecutable() is returning 'clang' only. It then
tries to access the /Headers directory and fails.
This issue has already been reported here for Debian systems,
but I confirm this is also an issue with Gentoo stable (glibc
2.6.1).
You can, in your mind, remove "Debian" and "Gentoo", and if it
pops up, also SUSE and Redhat and whatever, because it's a
generic linux problem.
Seo Sanghyeon already proposed a way to solve this:
"GetMainExecutable" is a tricky function to implement in
cross-platform way. The standard Linux method is to resolve
symlink /proc/self/exe. On Windows, you call GetModuleFileName.
See http://autopackage.org/docs/binreloc/ for extensive
discussion.
and I might even implement it, but I don't have much time for
this, so feel free to grab it and implement it faster.
Seo Sanghyeon already proposed a way to solve this:
"GetMainExecutable" is a tricky function to implement in
cross-platform way. The standard Linux method is to resolve
symlink /proc/self/exe. On Windows, you call GetModuleFileName.
See http://autopackage.org/docs/binreloc/ for extensive
discussion.
I added support for the /proc/self/exe method a few months ago, but only for Cygwin. I didn't switch Linux to using it because I didn't want to break something that I assumed was working.
All that's really required is a #define change, but the attached patch also uses /proc/self/exe instead of /proc/$$/exe. (/me slaps forehead.)