llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

ccc-analyzer is NO sufficient to build glibc

Open xiangzhai opened this issue 10 years ago • 9 comments

Bugzilla Link 31017
Version 3.9
OS Linux
CC @devincoughlin,@ppenzin,@rnk,@frobtech

Extended Description

mkdir scan-build cd scan-build/ scan-build -k -v -V ../configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --with-headers=/usr/include --with-bugurl=https://bugs.archlinux.org/ --enable-add-ons --enable-obsolete-rpc --enable-kernel=2.6.32 --enable-bind-now --disable-profile --enable-stackguard-randomization --enable-lock-elision --enable-multi-arch --disable-werror scan-build: Using '/usr/bin/clang-3.9' for static analysis checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for gcc... /usr/bin/../lib/clang/ccc-analyzer checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether /usr/bin/../lib/clang/ccc-analyzer accepts -g... yes checking for readelf... readelf checking whether we are using the GNU C++ compiler... yes checking whether /usr/bin/../lib/clang/c++-analyzer accepts -g... yes checking whether /usr/bin/../lib/clang/c++-analyzer can link programs... yes checking for sysdeps preconfigure fragments... aarch64 alpha arm hppa i386 m68k microblaze mips nacl nios2 powerpc s390 sh sparc tile x86_64 checking whether /usr/bin/../lib/clang/ccc-analyzer compiles in -mx32 mode by default... no

configure: running configure fragment for add-on libidn checking for assembler and linker STT_GNU_IFUNC support... yes checking for gcc attribute ifunc support... yes checking sysdep dirs... sysdeps/unix/sysv/linux/x86_64/64 sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86 sysdeps/unix/sysv/linux/wordsize-64 sysdeps/x86_64/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/x86_64 sysdeps/unix sysdeps/posix sysdeps/x86_64/64 sysdeps/x86_64/fpu/multiarch sysdeps/x86_64/fpu sysdeps/x86/fpu sysdeps/x86_64/multiarch sysdeps/x86_64 sysdeps/x86 sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64/wordsize-64 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/wordsize-64 sysdeps/ieee754 sysdeps/generic checking for a BSD-compatible install... /usr/bin/install -c checking whether ln -s works... yes checking whether as is GNU as... yes checking whether ld is GNU ld... yes checking for as... as checking version of as... 2.27, ok checking for ld... ld checking version of ld... 2.27, ok checking for gnumake... no checking for gmake... no checking for make... make checking version of make... 4.2.1, ok checking for gnumsgfmt... no checking for gmsgfmt... no checking for msgfmt... msgfmt checking version of msgfmt... 0.19.8.1, ok checking for makeinfo... makeinfo checking version of makeinfo... 6.3, ok checking for sed... sed checking version of sed... 4.2.2, ok checking for gawk... gawk checking version of gawk... 4.1.4, ok checking if /usr/bin/../lib/clang/ccc-analyzer is sufficient to build libc... no checking for nm... nm configure: error: *** These critical programs are missing or too old: compiler *** Check the INSTALL file for required versions. scan-build: Removing directory '/tmp/scan-build-2016-11-15-104214-11693-1' because it contains no reports. scan-build: No bugs found.

xiangzhai avatar Nov 15 '16 04:11 xiangzhai

If you think any individual compatibility issue is important enough to be worth fixing, you can file a separate issue with a reduced test case for each one.

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

xiangzhai avatar Dec 13 '16 04:12 xiangzhai

I don't see how a PCH diagnostic has anything to do with anything else in this bug.

Fundamentally, clang is not gcc, and therefore cannot be 100% compatible with every implementation detail. You are encountering normal compiler errors that arise when attempting to build code that does not yet build with clang. If you think any individual compatibility issue is important enough to be worth fixing, you can file a separate issue with a reduced test case for each one.

rnk avatar Dec 12 '16 18:12 rnk

We don't support renaming the LLVM IR global as we generate code. See https://llvm.org/bugs/show_bug.cgi?id=22830 for more info on this specific issue.

Hi Reid,

Thanks for your reply!

The "same" story for qtbase, but different Analyzer Failures, for example:

Other Error corelib/codecs/qsimplecodec.cpp error: no suitable precompiled header file found in directory '.pch/Qt5Core.gch' 1 error generated.

Regards, Leslie Zhai

xiangzhai avatar Dec 12 '16 04:12 xiangzhai

Yes, neither glibc or linux build with clang without patches. I know there has been interest in getting them to build with clang, but to some extent the burden is on those projects to be more portable and rely less on GCC implementation details.

I think the diagnostic you pasted is clear, and the implementation limitation reasonable. We don't support renaming the LLVM IR global as we generate code. See https://llvm.org/bugs/show_bug.cgi?id=22830 for more info on this specific issue.

rnk avatar Dec 07 '16 18:12 rnk

Hi llvm developers,

Clang Static Analyzer is kooool for analyzing code for K3B, KDE, Qt and other open source components http://www.leetcode.cn/2016/11/analyzing-code-for-kde-qt-open-source-components.html but it failed to analysis glibc - a lot of Analyzer Failures, for example:

In file included from check_fds.c:18: In file included from ../include/errno.h:27: In file included from ../sysdeps/x86_64/nptl/tls.h:27: In file included from ../include/stdlib.h:14: ../include/sys/stat.h:16:15: error: cannot apply asm label to function after its first use hidden_proto (__fxstat)

./../include/libc-symbols.h:420:19: note: expanded from macro 'hidden_proto'
  __hidden_proto (name, , __GI_##name, ##attrs)
  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:424:33: note: expanded from macro '__hidden_proto'
  extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
                                ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and the same story for Linux v4.x

Regards,
Leslie Zhai

xiangzhai avatar Dec 07 '16 10:12 xiangzhai

The plan of record was to leave the version at 4.2. Code that cares about post GCC 4.2 features is new enough that it can be migrated to __has_feature/__has_builtin etc.

As a workaround, I recommend running configure with plain GCC and then substituting the compiler after generating makefiles.

rnk avatar Nov 16 '16 00:11 rnk

It looks like this is happening because the configure script requires GCC 4.7+ and clang only claims to be compatible (via the preprocessor defines in InitPreprocessor.cpp) with GCC 4.2.1.

I wonder if we can bump the claimed compatibility?

devincoughlin avatar Nov 15 '16 21:11 devincoughlin

just comment AC_TRY_COMPILE for #error insufficient compiler https://sourceware.org/git/?p=glibc.git;a=blob;f=configure.ac;h=a64aeb9979a53cd7f69c20f6f38db75c7a1bdf49;hb=HEAD#l1006

xiangzhai avatar Nov 15 '16 08:11 xiangzhai

assigned to @tkremenek

xiangzhai avatar Nov 15 '16 04:11 xiangzhai