# LD and CXXFLAGS in make.conf are being ignored



## PaddyMac (May 5, 2018)

Clang 6 recently entered the ports tree, and I successfully set the CC, CXX, and CPP settings in /etc/make.conf to make Clang 6 from ports my default compiler. I'm running 11.1-RELEASE-p9, and it's going to be the default compiler, from what I understand, in 11.2-RELEASE, so I figured I'd go ahead and make the change. Everything seemed to be working well, so I wanted to get a little experimental and try setting Clang 6's lld linker as the default linker instead of the GNU bfd linkr in the base system. I also wanted to see how usable Clang 6's LTO is. So I added

LD=/usr/local/bin/ld.lld60
CFLAGS=-O2 -pipe
CXXFLAGS+=-flto

to /etc/make.conf

I then tried compiling a couple of different ports, and neither the linker being used changed to lld nor was -flto added to the C++ flags. I was only able to force lld to be used by making /usr/bin/ld a symlink to /usr/local/bin/ld.lld60, and I was able to get -flto to be added to the C++ flags by adding it to the CFLAGS line in /etc/make.conf. So the CFLAGS variable is respected, but neither the LD nor the CXXFLAGS variable is respected. I'd really rather not go tinkering with the base system and would rather use the "proper" methods of changing settings. Does anyone know what the problem might be and how to resolve this?


----------

