Llvm-as: <stdin>:1:1: error: expected top-level entity

Hi,

I am trying to build libclc through buildroot . llvm-14.0.6/clang-14.0.6 etc packages are built successfully prior to libclc build itself. libclc fails with below error.
{{
libclc-d1cbc92e2ceee59963f5c3a576382e5bba31f060.tar.gz: OK (sha256: 5ea2cd2fa7fa1474d3e0580064e7a22014ef8d64dbbd7c546277fa4beb5acf86)

libclc d1cbc92e2ceee59963f5c3a576382e5bba31f060 Extracting
gzip -d -c /root/build/build/buildroot-source/dl/libclc/libclc-d1cbc92e2ceee59963f5c3a576382e5bba31f060.tar.gz | /bin/tar --strip-components=1 -C /root/build/build/buildroot-build/build/libclc-d1cbc92e2ceee59963f5c3a576382e5bba31f060 -xf -
libclc d1cbc92e2ceee59963f5c3a576382e5bba31f060 Patching
libclc d1cbc92e2ceee59963f5c3a576382e5bba31f060 Configuring

LLVM-CC nvptx–nvidiacl/lib/atomic/atomic_and.cl.bc
LLVM-CC nvptx–nvidiacl/lib/atomic/atomic_cmpxchg.cl.bc
/bin/llvm-as: :1:1: error: expected top-level entity
typedef unsigned char uchar;
^
make[1]: *** [Makefile:75: nvptx–nvidiacl/lib/subnormal_helper_func.ll.bc] Error 1
make[1]: *** Waiting for unfinished jobs…
}}
Please provide input for further analysis.

Regards
Koti

The “typedef” line looks like C code. “llvm-as” is a bitcode assembler, it expects the textual form of LLVM IR (.ll), and creates the binary representation of it (.bc).

Hi,

libclc is not customized from my end, still the error mentioned in previous comment is observed? llvm-as path is passed and please check below path configuration before triggering libclc build.
{{

libclc d1cbc92e2ceee59963f5c3a576382e5bba31f060 Configuring
(cd /root/build/build/buildroot-build/build/libclc-d1cbc92e2ceee59963f5c3a576382e5bba31f060; PATH=“//bin://sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin” AR=“//bin/x86_64-linux-gnu-ar” AS=“//bin/x86_64-linux-gnu-as” LD=“//bin/x86_64-linux-gnu-ld” NM=“//bin/x86_64-linux-gnu-nm” CC=“//bin/x86_64-linux-gnu-gcc” GCC=“//bin/x86_64-linux-gnu-gcc” CPP=“//bin/x86_64-linux-gnu-cpp” CXX=“//bin/x86_64-linux-gnu-g++” FC=“//bin/x86_64-linux-gnu-gfortran” F77=“//bin/x86_64-linux-gnu-gfortran” RANLIB=“//bin/x86_64-linux-gnu-ranlib” READELF=“//bin/x86_64-linux-gnu-readelf” STRIP=“//bin/x86_64-linux-gnu-strip” OBJCOPY=“//bin/x86_64-linux-gnu-objcopy” OBJDUMP=“//bin/x86_64-linux-gnu-objdump” AR_FOR_BUILD=“/usr/bin/ar” AS_FOR_BUILD=“/usr/bin/as” CC_FOR_BUILD=“//bin/ccache /usr/bin/gcc” GCC_FOR_BUILD=“//bin/ccache /usr/bin/gcc” CXX_FOR_BUILD=“//bin/ccache /usr/bin/g++” LD_FOR_BUILD=“/usr/bin/ld” CPPFLAGS_FOR_BUILD=“-I//include” CFLAGS_FOR_BUILD=“-O2 -I//include” CXXFLAGS_FOR_BUILD=“-O2 -I//include” LDFLAGS_FOR_BUILD=“-L//lib -Wl,-rpath,//lib” FCFLAGS_FOR_BUILD=“” DEFAULT_ASSEMBLER=“//bin/x86_64-linux-gnu-as” DEFAULT_LINKER=“//bin/x86_64-linux-gnu-ld” CPPFLAGS=“-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64” CFLAGS=“-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g2 -D_FORTIFY_SOURCE=1” CXXFLAGS=“-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g2 -D_FORTIFY_SOURCE=1” LDFLAGS=“” FCFLAGS=" -Os -g2" FFLAGS=" -Os -g2" PKG_CONFIG=“//bin/pkg-config” STAGING_DIR=“//x86_64-linux-gnu/sysroot” INTLTOOL_PERL=/usr/bin/perl ./configure.py -with-llvm-config=//usr/bin/llvm-config -prefix=/usr -includedir=/usr/share -pkgconfigdir=/usr/lib/pkgconfig -with-cxx-compiler=/usr/bin/g++)
}}
To get rid of the error, what’s the fix patch i need to apply? can you please let me know?

Hi,
⚙ D99794 libclc: Add -cl-no-stdinc to clang flags on clang >=13 is not useful as i am using llvm-14.0.6 version and the patch proposed in above link is already exists.

Regards