Bug 103388 - Linking libcltgsi.la (llvm/codegen/libclllvm_la-common.lo) fails with "error: no match for 'operator-'" with GCC-7, Mesa from Git and current LLVM revisions
Summary: Linking libcltgsi.la (llvm/codegen/libclllvm_la-common.lo) fails with "error:...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2017-10-21 10:38 UTC by network723
Modified: 2017-10-26 03:46 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Build log of failing build (96.89 KB, application/x-xz; charset=binary)
2017-10-21 11:59 UTC, Kai
Details

Description network723 2017-10-21 10:38:30 UTC
Trying to build Mesa master commit 0fdd531457ecaba263e6a27e030d451774f54b32 with llvm trunk revision 316259, but build fails with message:

[  305s] llvm/codegen/common.cpp:132:52: error: no match for 'operator-' (operand types are 'clang::LangAS' and 'const int')

Build finished successfully with gcc 4.8, but fails with gcc 5.x, 6.x and 7.x
Comment 1 network723 2017-10-21 10:40:20 UTC
My build options: ./configure --host=x86_64-suse-linux-gnu --build=x86_64-suse-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/lib --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --enable-llvm --enable-llvm-shared-libs --with-gallium-drivers=swrast,r600,r300,nouveau,radeonsi,svga,virgl --with-dri-drivers=i965,i915,r200,radeon --enable-debug --enable-shared-glapi --enable-glx-tls --enable-dri3 --enable-asm --enable-nine --enable-texture-float --enable-gallium-extra-hud --enable-lmsensors --with-platforms=x11,drm --enable-opencl --enable-opencl-icd --with-clang-libdir=/usr/lib64/ --with-platforms=x11,wayland,drm --with-vulkan-drivers=radeon,intel --enable-xa --enable-va --enable-vdpau --enable-omx-bellagio --disable-xvmc --enable-gbm --enable-gles1 --enable-gles2 --with-dri-searchpath=/usr/lib64/dri
Comment 2 Kai 2017-10-21 11:59:40 UTC
Created attachment 134973 [details]
Build log of failing build

I have the same issue in a clean pbuilder chroot of Debian Sid, exact versions are:
- Mesa: Git:master/24fe4e6143
- libdrm: Git:master/e580be90e8 (tag: libdrm-2.4.85)
- LLVM: SVN:trunk/r316233 (6.0 devel)
- GCC: 7.2.0-11

The full build log, including configure line, is attached.

The error is:
> libtool: link: ar cru .libs/libcltgsi.a tgsi/.libs/libcltgsi_la-compiler.o 
> libtool: link: ranlib .libs/libcltgsi.a
> libtool: link: ( cd ".libs" && rm -f "libcltgsi.la" && ln -s "../libcltgsi.la" "libcltgsi.la" )
> ../../../../../src/gallium/state_trackers/clover/llvm/codegen/common.cpp: In function 'std::vector<clover::module::argument> {anonymous}::make_kernel_args(const llvm::Module&, const string&, const clang::CompilerInstance&)':
> ../../../../../src/gallium/state_trackers/clover/llvm/codegen/common.cpp:132:52: error: no match for 'operator-' (operand types are 'clang::LangAS' and 'const int')
>                 if (address_space == address_spaces[clang::LangAS::opencl_local
>                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                                                     - compat::lang_as_offset]) {
>                                                     ^~~~~~~~
> Makefile:924: recipe for target 'llvm/codegen/libclllvm_la-common.lo' failed
> make[5]: *** [llvm/codegen/libclllvm_la-common.lo] Error 1
> make[5]: *** Waiting for unfinished jobs....
Comment 3 Andy Furniss 2017-10-21 15:18:23 UTC
Don't know why it would work with 4.8, but it's a known issue.

You could remove --enable-opencl as a temp workaround or apply this patch until the alternate fix that's discussed goes in.

https://patchwork.freedesktop.org/patch/182916/
Comment 4 Kai 2017-10-21 16:44:10 UTC
(In reply to Andy Furniss from comment #3)
> Don't know why it would work with 4.8, but it's a known issue.

Sorry, should have made that clear in my comment: I only tested the GCC from Debian's 7.2.0-11 package. I have no idea, if an older GCC would have worked.

> You could remove --enable-opencl as a temp workaround or apply this patch
> until the alternate fix that's discussed goes in.
> 
> https://patchwork.freedesktop.org/patch/182916/

Thanks, the patch works. You can have my
 Tested-by: Kai Wasserbäch <kai@dev.carbon-project.org>
for it.
Comment 5 Jan Vesely 2017-10-26 03:46:28 UTC
Fixed by a6d38f476beaaf0a9677cfc168172121b5779570

clover: Fix compilation after clang r315871


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.