# compiling freebsd with a modified clang compiler causes cryptic errors.



## dsaleem (Jun 22, 2022)

Hi.
I have been trying to compile the freebsd kernel and then world with the gllvm whole program compiler.
My current version is 12.1 on an ARM machine.
This is what my /etc/make.conf looks like

```
CC=gclang
CXX=gclang++
CPP=clang-cpp
```
I tried compiling the kernel using source code from version 12 and the kernel compiled fine. I then tried compiling the world, which resulted in the following error

```
-arguments -I/usr/obj/usr/src/arm64.aarch64/tmp/usr/include/private -I/usr/src/contrib/googletest/googlemock/include -I/usr/src/contrib/googletest/googlemock -I/usr/src/contrib/googletest/googletest/include -I/usr/src/contrib/googletest/googletest -I/usr/obj/usr/src/arm64.aarch64/tmp/usr/include/private -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -Wno-deprecated-copy -Wno-signed-unsigned-wchar -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -Wno-deprecated-copy -Wno-signed-unsigned-wchar -std=c++11 -Wno-deprecated-declarations -Wno-deprecated-copy -Wno-c++11-extensions   -o gmock-matchers_test  gmock-matchers_test.o -lprivategmock_main -lprivategmock -lprivategtest -lprivategmock -lprivategtest -lprivategtest
ld: error: gmock-matchers_test.o: SHT_SYMTAB_SHNDX has 102257 entries, but the symbol table associated has 141858
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR:Failed to compile using given arguments:
clang++ [-O2 -pipe -fno-common -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls -Wmissing-variable-declarations -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-variable -O0 -g0 -Qunused-arguments -I/usr/obj/usr/src/arm64.aarch64/tmp/usr/include/private -I/usr/src/contrib/googletest/googlemock/include -I/usr/src/contrib/googletest/googlemock -I/usr/src/contrib/googletest/googletest/include -I/usr/src/contrib/googletest/googletest -I/usr/obj/usr/src/arm64.aarch64/tmp/usr/include/private -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -Wno-deprecated-copy -Wno-signed-unsigned-wchar -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -Wno-deprecated-copy -Wno-signed-unsigned-wchar -std=c++11 -Wno-deprecated-declarations -Wno-deprecated-copy -Wno-c++11-extensions -o gmock-matchers_test gmock-matchers_test.o -lprivategmock_main -lprivategmock -lprivategtest -lprivategmock -lprivategtest -lprivategtest]
exit status: exit status 1
*** Error code 1
```

I looked at the guide and realized from the following that I should compile a newer version.

```
The build world process assumes an upgrade from an older    FreeBSD version using the source of a newer version that was    obtained using the instructions in [URL='https://people.freebsd.org/~rodrigc/doc/handbook/synching.html']Section 24.5, “Synchronizing Source”[/URL].
```

So I procured the 12.2 version and compiled which resulted in the following:


```
/usr/src/sys/kern/subr_sbuf.c:379:1: error: static declaration of 'sbuf_drain' follows non-static declaration
sbuf_drain(struct sbuf *s)
^
/usr/include/sys/sbuf.h:96:7: note: previous declaration is here
int              sbuf_drain(struct sbuf *);
                 ^
/usr/src/sys/kern/subr_sbuf.c:379:1: error: static declaration of 'sbuf_drain' follows non-static declaration
sbuf_drain(struct sbuf *s)
^
/usr/include/sys/sbuf.h:96:7: note: previous declaration is here
int              sbuf_drain(struct sbuf *);
```
 
I couldn't find how to format the logs properly, so I used quotes, apologies if that is incorrect.


----------

