Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when compiling using clang #37

Closed
Kodehawa opened this issue Nov 10, 2020 · 2 comments
Closed

Error when compiling using clang #37

Kodehawa opened this issue Nov 10, 2020 · 2 comments

Comments

@Kodehawa
Copy link

Kodehawa commented Nov 10, 2020

I'm not sure if I'm missing anything go-specific here. I've seen people compiling go projects with clang since forever, so I'm not really sure if I'm missing some go-specific environment variable here.

Compile flags:

export CC=clang
export CXX=clang++
export LD=/usr/bin/ld.lld
export AR="llvm-ar"
export NM="llvm-nm"
export RANLIB="llvm-ranlib"

# qmake stuff
export QMAKE_CC=clang
export QMAKE_CXX=clang++
export QMAKE_LINK=/usr/bin/ld.lld
export QMAKESPEC=linux-clang

CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"

# -Wno-error=range-loop-construct is for MultiMC, else it fails to build
CFLAGS="-march=znver1 -mtune=znver1 -flto=thin -O2 -pipe -fno-plt -Wno-error=range-loop-construct -Wno-long-long -Wno-cast-align"
CXXFLAGS+="${CFLAGS}"
LDFLAGS="-fuse-ld=lld -Wl,-O1,--sort-common,--as-needed,-z,relro,--thinlto-cache-dir=/home/kodehawa/.local/share/makepkg/cache/clang"
#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS="-j12"

#-- Debugging flags
DEBUG_CFLAGS="-g"
DEBUG_CXXFLAGS="-g"

# Rust flags
RUSTFLAGS="-C opt-level=2 -C target-cpu=native"

Error message:

go build ./cmd/sbctl
# net
cannot parse gcc output $WORK/b070//_cgo_.o as ELF, Mach-O, PE, XCOFF object
make: *** [Makefile:22: sbctl] Error 2
make: *** Waiting for unfinished jobs....

Thanks you ❤️

@Foxboron
Copy link
Owner

I don't know how to use clang for this and I'm probably not spending time on it. Can reopen if anyone comes forth with any suggestions :) Thanks

@ericonr
Copy link
Contributor

ericonr commented Dec 19, 2021

CFLAGS="... -flto=thin ..."
cannot parse gcc output $WORK/b070//cgo.o as ELF, Mach-O, PE, XCOFF object

The object file has LLVM bitcode instead of being a proper ELF file. The issue isn't clang, it's ThinLTO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants