# Problem building firefox with clang



## demonking (May 12, 2013)

Hello,

*I* have installed freebsd9.0 FreeBSD 9.0 the 3rd third time with clang, the first two without any problems. Now my harddisk died, so *I* have to reinstall it on an another one. The *p*roblem is, *I* get some strange error messages, when *I*'m trying to build *F*irefox or *C*hromium.


```
# pwd
/usr/ports/www/firefox

# make install clean

===>   firefox-20.0,1 depends on package: nspr>=4.9.4 - found
===>   firefox-20.0,1 depends on package: nss>=3.14.3 - not found
===>    Verifying install for nss>=3.14.3 in /usr/ports/security/nss
===>  Building for nss-3.14.3
gmake -C ../coreconf
gmake[1]: Entering directory `/usr/ports/security/nss/work/nss-

...

cd lib; gmake libs
gmake[1]: Entering directory `/usr/ports/security/nss/work/nss-3.14.3/mozilla/security/nss/lib'
cd util; gmake libs
gmake[2]: Entering directory `/usr/ports/security/nss/work/nss-3.14.3/mozilla/security/nss/lib/util'
rm -f FreeBSD9.0_OPT.OBJ/libnssutil3.so.1
clang -Wl,-Bsymbolic -shared -Wl,-soname -Wl,libnssutil3.so.1 -pthread -Wl,--version-script,FreeBSD9.0_OPT.OBJ/nssutil.def -o FreeBSD9.0_OPT.OBJ/libnssutil3.so.1 FreeBSD9.0_OPT.OBJ/quickder.o FreeBSD9.0_OPT.OBJ/secdig.o FreeBSD9.0_OPT.OBJ/derdec.o FreeBSD9.0_OPT.OBJ/derenc.o FreeBSD9.0_OPT.OBJ/dersubr.o FreeBSD9.0_OPT.OBJ/dertime.o FreeBSD9.0_OPT.OBJ/errstrs.o FreeBSD9.0_OPT.OBJ/nssb64d.o FreeBSD9.0_OPT.OBJ/nssb64e.o FreeBSD9.0_OPT.OBJ/nssrwlk.o FreeBSD9.0_OPT.OBJ/nssilock.o FreeBSD9.0_OPT.OBJ/oidstring.o FreeBSD9.0_OPT.OBJ/portreg.o FreeBSD9.0_OPT.OBJ/secalgid.o FreeBSD9.0_OPT.OBJ/secasn1d.o FreeBSD9.0_OPT.OBJ/secasn1e.o FreeBSD9.0_OPT.OBJ/secasn1u.o FreeBSD9.0_OPT.OBJ/secitem.o FreeBSD9.0_OPT.OBJ/secload.o FreeBSD9.0_OPT.OBJ/secoid.o FreeBSD9.0_OPT.OBJ/sectime.o FreeBSD9.0_OPT.OBJ/secport.o FreeBSD9.0_OPT.OBJ/templates.o FreeBSD9.0_OPT.OBJ/utf8.o FreeBSD9.0_OPT.OBJ/utilmod.o FreeBSD9.0_OPT.OBJ/utilpars.o    -L../../../../dist/FreeBSD9.0_OPT.OBJ/lib -L../../../../dist/FreeBSD9.0_OPT.OBJ/lib -lplc4 -lplds4 -lnspr4  -pthread
/usr/bin/ld: cannot find -lplc4
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [FreeBSD9.0_OPT.OBJ/libnssutil3.so.1] Error 1
gmake[2]: Leaving directory `/usr/ports/security/nss/work/nss-3.14.3/mozilla/security/nss/lib/util'
gmake[1]: *** [libs] Error 2
gmake[1]: Leaving directory `/usr/ports/security/nss/work/nss-3.14.3/mozilla/security/nss/lib'
gmake: *** [libs] Error 2
*** Error code 1

Stop in /usr/ports/security/nss.
*** Error code 1

Stop in /usr/ports/www/firefox.
*** Error code 1

Stop in /usr/ports/www/firefox.
```

I have checked if libplc4 exists:


```
# ls -l /usr/local/lib/libplc4.*

-rw-r--r--  1 root  wheel   31916 May 12 12:01 /usr/local/lib/libplc4.a
lrwxr-xr-x  1 root  wheel      12 May 12 12:01 /usr/local/lib/libplc4.so -> libplc4.so.1
-r-xr-xr-x  1 root  wheel  205424 May 12 12:01 /usr/local/lib/libplc4.so.1
```

I have also tried to reinstall devel/nspr, *t*he error still happens. Someone any idea?

Greetz
demonking


----------



## cpm@ (May 12, 2013)

```
<snip>
cd lib; gmake libs
gmake[1]: Entering directory `/usr/ports/security/nss/work/nss-3.14.3/mozilla/security/nss/lib'
cd util; gmake libs
gmake[2]: Entering directory `/usr/ports/security/nss/work/nss-3.14.3/mozilla/security/nss/lib/util'
rm -f FreeBSD9.0_OPT.OBJ/libnssutil3.so.1
clang -Wl,-Bsymbolic -shared -Wl,-soname -Wl,libnssutil3.so.1 -pthread -Wl,--version-script,FreeBSD9.0_OPT.OBJ/nssutil.def -o FreeBSD9.0_OPT.OBJ/libnssutil3.so.1 FreeBSD9.0_OPT.OBJ/quickder.o FreeBSD9.0_OPT.OBJ/secdig.o FreeBSD9.0_OPT.OBJ/derdec.o FreeBSD9.0_OPT.OBJ/derenc.o FreeBSD9.0_OPT.OBJ/dersubr.o FreeBSD9.0_OPT.OBJ/dertime.o FreeBSD9.0_OPT.OBJ/errstrs.o FreeBSD9.0_OPT.OBJ/nssb64d.o FreeBSD9.0_OPT.OBJ/nssb64e.o FreeBSD9.0_OPT.OBJ/nssrwlk.o FreeBSD9.0_OPT.OBJ/nssilock.o FreeBSD9.0_OPT.OBJ/oidstring.o FreeBSD9.0_OPT.OBJ/portreg.o FreeBSD9.0_OPT.OBJ/secalgid.o FreeBSD9.0_OPT.OBJ/secasn1d.o FreeBSD9.0_OPT.OBJ/secasn1e.o FreeBSD9.0_OPT.OBJ/secasn1u.o FreeBSD9.0_OPT.OBJ/secitem.o FreeBSD9.0_OPT.OBJ/secload.o FreeBSD9.0_OPT.OBJ/secoid.o FreeBSD9.0_OPT.OBJ/sectime.o FreeBSD9.0_OPT.OBJ/secport.o FreeBSD9.0_OPT.OBJ/templates.o FreeBSD9.0_OPT.OBJ/utf8.o FreeBSD9.0_OPT.OBJ/utilmod.o FreeBSD9.0_OPT.OBJ/utilpars.o    -L../../../../dist/FreeBSD9.0_OPT.OBJ/lib -L../../../../dist/FreeBSD9.0_OPT.OBJ/lib -lplc4 -lplds4 -lnspr4  -pthread
/usr/bin/ld: cannot find -lplc4
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [FreeBSD9.0_OPT.OBJ/libnssutil3.so.1] Error 1
gmake[2]: Leaving directory `/usr/ports/security/nss/work/nss-3.14.3/mozilla/security/nss/lib/util'
gmake[1]: *** [libs] Error 2
gmake[1]: Leaving directory `/usr/ports/security/nss/work/nss-3.14.3/mozilla/security/nss/lib'
gmake: *** [libs] Error 2
*** Error code 1
<snip>
```

Add this line in /usr/ports/security/nss/Makefile

```
LDFLAGS+=       -L${LOCALBASE}/lib
```
and remove this one instead:

```
MAKE_ENV=      LIBRARY_PATH="${LOCALBASE}/lib" \
```


```
--- Makefile.orig       2013-05-12 18:53:30.000000000 +0200
+++ Makefile    2013-05-12 18:59:47.000000000 +0200
@@ -22,11 +22,11 @@
 USE_LDCONFIG=  ${PREFIX}/lib/nss
 USE_GMAKE=     yes
 USE_PERL5_BUILD=yes
-MAKE_ENV=      LIBRARY_PATH="${LOCALBASE}/lib" \
-               SQLITE_INCLUDE_DIR="${LOCALBASE}/include" \
+MAKE_ENV=      SQLITE_INCLUDE_DIR="${LOCALBASE}/include" \
                NSS_ENABLE_ECC=1 NSS_USE_SYSTEM_SQLITE=1
 ALL_TARGET=    nss_build_all
 CFLAGS+=       -I${LOCALBASE}/include/nspr
+LDFLAGS+=       -L${LOCALBASE}/lib
 
 SUB_FILES=     nss-config nss.pc
 SUB_LIST=      MAJOR_VERSION=${PORTVERSION:R:R} \
```

Other possible solution is use LD_LIBRARY_PATH instead of LIBRARY_PATH variable, the fundamental difference between these variables are LD_LIBRARY_PATH is searched when the program starts, LIBRARY_PATH is searches at link time.

Note that you should use gcc(1)

```
[B]LIBRARY_PATH[/B]
	   The value of LIBRARY_PATH is a colon-separated list of directories,
	   much like PATH.  When configured as a native compiler, GCC tries
	   the directories thus specified when searching for special linker
	   files, if it can't find them using GCC_EXEC_PREFIX.	Linking using
	   GCC also uses these directories when searching for ordinary
	   libraries for the -l option (but directories specified with -L come
	   first).
```

Compile with clang(1) causes problems as you have, read the following question for an explanation.

Reference: http://www.freebsd.org/doc/en/books/porters-handbook/porting-prefix.html.


----------



## pkubaj (May 12, 2013)

9.0 is unsupported, thus packages may not compile. Upgrade to 9.1.


----------



## demonking (May 12, 2013)

cpu82 said:
			
		

> ```
> Other possible solution is use [FILE]LD_LIBRARY_PATH[/FILE] instead of [FILE]LIBRARY_PATH[/FILE] variable, the fundamental difference between these variables are [FILE]LD_LIBRARY_PATH[/FILE] is searched when the program starts, [FILE]LIBRARY_PATH[/FILE] is searches at link time.
> 
> Reference: [url=http://www.freebsd.org/doc/en/books/porters-handbook/porting-prefix.html]http://www.freebsd.org/doc/en/books/porters-handbook/porting-prefix.html[/url].[/quote]
> ...


----------



## cpm@ (May 12, 2013)

No, I meant that change line 25 in Makefile

```
-MAKE_ENV=      LIBRARY_PATH="${LOCALBASE}/lib" \
+MAKE_ENV=      LD_LIBRARY_PATH="${LOCALBASE}/lib" \
```



			
				demonking said:
			
		

> Why should it be unsupported?
> It's only an linker issue.



FreeBSD 9.0 reached EOL (End-Of-Life) on March 31, 2013. Update your system is your best bet


----------



## demonking (May 12, 2013)

cpu82 said:
			
		

> No, I meant that change line 25 in Makefile
> 
> ```
> -MAKE_ENV=      LIBRARY_PATH="${LOCALBASE}/lib" \
> ...



Still the same.



			
				cpu82 said:
			
		

> FreeBSD 9.0 reached EOL (End-Of-Life) on March 31, 2013.



*O*h, th*e*n *I* postponed for too long. I will update my sy*s*tem now


----------



## cpm@ (May 12, 2013)

Seems that www/firefox compiles using GCC47 or later. See ports/177728.


----------



## demonking (May 12, 2013)

cpu82 said:
			
		

> Seems that www/firefox compiles using GCC47 or later. See ports/177728.



Maybe. When *I* tried to compile *C*hromium, *I* used the WITH_CLANG option. But still the same error as in *F*irefox.


Edit:

I was my FreeBSD Version  
I will check it now each week, that some kind of errors don't happen


----------

