# FreeBSD With Other Compilers



## Felix S (Jul 1, 2016)

Hi Everyone!

I have read the article about compiling FreeBSD using Clang/LLVM (https://wiki.freebsd.org/BuildingFreeBSDWithClang). Coming from a Linux background, I had tasks which required me to rebuild the Linux kernel using Intel's C++ compiler.

I decided it would be a pretty interesting experiment to rebuild FreeBSD using the new Intel System Studio which they have modified to support FreeBSD. I proceeded in the following fashion:

I added the following lines to my etc/make.conf file (similarly as it was shown for Clang):


```
CC=/opt/intel/system_studio_freebsd_2016.3.024/bin/intel64/icl
CXX=/opt/intel/system_studio_freebsd_2016.3.024/bin/intel64/icl++
CPP=/opt/intel/system_studio_freebsd_2016.3.024/bin/intel64/icl++
```

Everything seems to go right until the following I receive the following error:


```
===> include/rpcsvc (buildincludes)
RPCGEN_CPP=/opt/intel/system_studio_freebsd_2016.3.024/bin/intel64/icl++ rpcgen -C -h -DWANT_NFS3 /usr/src/include/rpcsvc/key_prot.x -o key_prot.h
ld:/usr/src/include/rpcsvc/key_prot.x: file format not recognized; treating as linker script
ld:/usr/src/include/rpcsvc/key_prot.x:1: syntax error
*** Error code 1
```

I remember reading that Clang was also prone to RPC errors - does anyone have any advice regarding my endeavour of building FreeBSD using Intel's kit?


----------



## kpedersen (Jul 1, 2016)

Nice. Had no idea that Intel supports FreeBSD for their compilers.

First release was 13th August 2015. They certainly didn't advertise that!


----------



## kpa (Jul 1, 2016)

Double check that your definition for CPP which is the C preprocessor is correct, setting it to icl++ looks wrong to me. With other compilers you have to use for example clang-cpp or gcc -E.


----------



## Felix S (Jul 2, 2016)

Right. My mistake!

For those who are interested, the Make.conf needs to be specified as:


```
CC=/opt/intel/system_studio_freebsd_2016.3.024/bin/intel64/icl
CXX=/opt/intel/system_studio_freebsd_2016.3.024/bin/intel64/icl++
CPP=/opt/intel/system_studio_freebsd_2016.3.024/bin/intel64/icl -P
COMPILER_TYPE="ICL"
```

Do not use -E - it results in RPC errors just like it does for Clang.

Unfortunately, this only partially solves the problem - the build world fails at stage 4.2 (libraries).


```
/opt/intel/system_studio_freebsd_2016.3.024/bin/intel64/icl -c -O2 -pipe   -DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -DHAVE_GTHR_DEFAULT  -I/usr/src/gnu/lib/libgcc/../../../contrib/gcclibs/include  -I/usr/src/gnu/lib/libgcc/../../../contrib/gcc/config -I/usr/src/gnu/lib/libgcc/../../../contrib/gcc -I.  -I/usr/src/gnu/lib/libgcc/../../usr.bin/cc/cc_tools -std=gnu99    -fvisibility=hidden -DHIDE_EXPORTS -fPIC -fexceptions -D__GLIBC__=3 -DElfW=__ElfN -o unwind-dw2.o /usr/src/gnu/lib/libgcc/../../../contrib/gcc/unwind-dw2.c

<unknown file>(0) (col 0): internal error: 010101_1141

compilation aborted for /usr/src/gnu/lib/libgcc/../../../contrib/gcc/unwind-dw2.c (code 1)
```

After some digging in the sources, I figured out it was failing because unwind-dw2.c references two header files which are nowhere to be found:

1) #include "tconfig.h"
2) #include "tm.h"

The other referenced files seem to be in place and found. Apparently this has something to do with the evil gcc compiler... anyone have any clue or suggestions on this issue?


----------

