# How to build nss?



## zoujiaqing (Feb 7, 2018)

I want build it.


```
# tar xvf nss-3.35.tar.gz
# cd nss-3.35/nss/
# patch < /usr/ports/security/nss/files/patch-*
# export NSPR_INCLUDE_DIR=/usr/local/include/nspr
# export NSPR_LIB_DIR=/usr/local/lib
# gmake nss_build_all
```

error:

```
intel-gcm.s:1187: Error: no such instruction: `vpaddd .Lone(%rip),CTR,CTR'
intel-gcm.s:1189: Error: no such instruction: `vpxor (KS),TMP1,TMP1'
intel-gcm.s:1190: Error: no such instruction: `vaesenc 16*1(KS),TMP1,TMP1'
intel-gcm.s:1191: Error: no such instruction: `vaesenc 16*2(KS),TMP1,TMP1'
intel-gcm.s:1192: Error: no such instruction: `vaesenc 16*3(KS),TMP1,TMP1'
intel-gcm.s:1193: Error: no such instruction: `vaesenc 16*4(KS),TMP1,TMP1'
intel-gcm.s:1194: Error: no such instruction: `vaesenc 16*5(KS),TMP1,TMP1'
intel-gcm.s:1195: Error: no such instruction: `vaesenc 16*6(KS),TMP1,TMP1'
intel-gcm.s:1196: Error: no such instruction: `vaesenc 16*7(KS),TMP1,TMP1'
intel-gcm.s:1197: Error: no such instruction: `vaesenc 16*8(KS),TMP1,TMP1'
intel-gcm.s:1198: Error: no such instruction: `vaesenc 16*9(KS),TMP1,TMP1'
intel-gcm.s:1199: Error: no such instruction: `vmovdqu 16*10(KS),TMP2'
intel-gcm.s:1202: Error: no such instruction: `vaesenc 16*10(KS),TMP1,TMP1'
intel-gcm.s:1203: Error: no such instruction: `vaesenc 16*11(KS),TMP1,TMP1'
intel-gcm.s:1204: Error: no such instruction: `vmovdqu 16*12(KS),TMP2'
intel-gcm.s:1207: Error: no such instruction: `vaesenc 16*12(KS),TMP1,TMP1'
intel-gcm.s:1208: Error: no such instruction: `vaesenc 16*13(KS),TMP1,TMP1'
intel-gcm.s:1209: Error: no such instruction: `vmovdqu 16*14(KS),TMP2'
intel-gcm.s:1211: Error: no such instruction: `vaesenclast TMP2,TMP1,TMP1'
intel-gcm.s:1213: Error: no such instruction: `vpxor (CT),TMP1,TMP1'
intel-gcm.s:1214: Error: no such instruction: `vmovdqu TMP1,(PT)'
intel-gcm.s:1224: Error: no such instruction: `vpshufb .Lbswap_mask(%rip),CTR,TMP1'
intel-gcm.s:1225: Error: no such instruction: `vpaddd .Lone(%rip),CTR,CTR'
intel-gcm.s:1227: Error: no such instruction: `vpxor (KS),TMP1,TMP1'
intel-gcm.s:1228: Error: no such instruction: `vaesenc 16*1(KS),TMP1,TMP1'
intel-gcm.s:1229: Error: no such instruction: `vaesenc 16*2(KS),TMP1,TMP1'
intel-gcm.s:1230: Error: no such instruction: `vaesenc 16*3(KS),TMP1,TMP1'
intel-gcm.s:1231: Error: no such instruction: `vaesenc 16*4(KS),TMP1,TMP1'
intel-gcm.s:1232: Error: no such instruction: `vaesenc 16*5(KS),TMP1,TMP1'
intel-gcm.s:1233: Error: no such instruction: `vaesenc 16*6(KS),TMP1,TMP1'
intel-gcm.s:1234: Error: no such instruction: `vaesenc 16*7(KS),TMP1,TMP1'
intel-gcm.s:1235: Error: no such instruction: `vaesenc 16*8(KS),TMP1,TMP1'
intel-gcm.s:1236: Error: no such instruction: `vaesenc 16*9(KS),TMP1,TMP1'
intel-gcm.s:1237: Error: no such instruction: `vmovdqu 16*10(KS),TMP2'
intel-gcm.s:1240: Error: no such instruction: `vaesenc 16*10(KS),TMP1,TMP1'
intel-gcm.s:1241: Error: no such instruction: `vaesenc 16*11(KS),TMP1,TMP1'
intel-gcm.s:1242: Error: no such instruction: `vmovdqu 16*12(KS),TMP2'
intel-gcm.s:1245: Error: no such instruction: `vaesenc 16*12(KS),TMP1,TMP1'
intel-gcm.s:1246: Error: no such instruction: `vaesenc 16*13(KS),TMP1,TMP1'
intel-gcm.s:1247: Error: no such instruction: `vmovdqu 16*14(KS),TMP2'
intel-gcm.s:1250: Error: no such instruction: `vaesenclast TMP2,TMP1,TMP1'
intel-gcm.s:1252: Error: no such instruction: `vpxor TMP2,TMP2,TMP2'
intel-gcm.s:1253: Error: no such instruction: `vmovdqa TMP2,(%rsp)'
intel-gcm.s:1271: Error: no such instruction: `vmovdqa (%rsp),TMP0'
intel-gcm.s:1272: Error: no such instruction: `vpxor TMP0,TMP1,TMP1'
intel-gcm.s:1274: Error: no such instruction: `vmovdqa TMP1,(%rsp)'
intel-gcm.s:1285: Error: no such instruction: `vpshufb .Lbswap_mask(%rip),TMP0,TMP0'
intel-gcm.s:1286: Error: no such instruction: `vpxor TMP0,T,T'
intel-gcm.s:1287: Error: no such instruction: `vmovdqu (Htbl),TMP0'
intel-gcm.s:1291: Error: no such instruction: `vpshufb .Lbswap_mask(%rip),T,T'
intel-gcm.s:1292: Error: no such instruction: `vpshufb .Lbswap_mask(%rip),CTR,CTR'
intel-gcm.s:1293: Error: no such instruction: `vmovdqu T,272(Gctx)'
intel-gcm.s:1294: Error: no such instruction: `vmovdqu CTR,288(Gctx)'
intel-gcm.s:1311: Error: no such instruction: `vpclmulqdq $0x00,TMP0,T,TMP1'
intel-gcm.s:1312: Error: no such instruction: `vpclmulqdq $0x11,TMP0,T,TMP4'
intel-gcm.s:1314: Error: no such instruction: `vpshufd $78,T,TMP2'
intel-gcm.s:1315: Error: no such instruction: `vpshufd $78,TMP0,TMP3'
intel-gcm.s:1316: Error: no such instruction: `vpxor T,TMP2,TMP2'
intel-gcm.s:1317: Error: no such instruction: `vpxor TMP0,TMP3,TMP3'
intel-gcm.s:1319: Error: no such instruction: `vpclmulqdq $0x00,TMP3,TMP2,TMP2'
intel-gcm.s:1320: Error: no such instruction: `vpxor TMP1,TMP2,TMP2'
intel-gcm.s:1321: Error: no such instruction: `vpxor TMP4,TMP2,TMP2'
intel-gcm.s:1323: Error: no such instruction: `vpslldq $8,TMP2,TMP3'
intel-gcm.s:1324: Error: no such instruction: `vpsrldq $8,TMP2,TMP2'
intel-gcm.s:1326: Error: no such instruction: `vpxor TMP3,TMP1,TMP1'
intel-gcm.s:1327: Error: no such instruction: `vpxor TMP2,TMP4,TMP4'
intel-gcm.s:1329: Error: no such instruction: `vpclmulqdq $0x10,.Lpoly(%rip),TMP1,TMP2'
intel-gcm.s:1330: Error: no such instruction: `vpshufd $78,TMP1,TMP3'
intel-gcm.s:1331: Error: no such instruction: `vpxor TMP3,TMP2,TMP1'
intel-gcm.s:1333: Error: no such instruction: `vpclmulqdq $0x10,.Lpoly(%rip),TMP1,TMP2'
intel-gcm.s:1334: Error: no such instruction: `vpshufd $78,TMP1,TMP3'
intel-gcm.s:1335: Error: no such instruction: `vpxor TMP3,TMP2,TMP1'
intel-gcm.s:1337: Error: no such instruction: `vpxor TMP4,TMP1,T'
cc: error: assembler command failed with exit code 1 (use -v to see invocation)
make[3]: *** [../../coreconf/rules.mk:417: FreeBSD11.1_64_OPT.OBJ/FreeBSD_SINGLE_SHLIB/intel-gcm.o] Error 1
make[3]: Leaving directory '/usr/home/zoujiaqing/rpmbuild/BUILD/nss-3.35/nss/lib/freebl'
make[2]: *** [Makefile:632: libs] Error 2
make[2]: Leaving directory '/usr/home/zoujiaqing/rpmbuild/BUILD/nss-3.35/nss/lib/freebl'
make[1]: *** [../coreconf/rules.mk:101: libs] Error 2
make[1]: Leaving directory '/usr/home/zoujiaqing/rpmbuild/BUILD/nss-3.35/nss/lib'
make: *** [coreconf/rules.mk:101: libs] Error 2
```

I use ports to build is successed, but my self compile failed.

My FreeBSD version is 11.1


----------



## sidetone (Feb 7, 2018)

Building of Mozilla ports (Firefox, Thunderbird, NSS) has been problematic recently. If it doesn't work after I adjust the settings, and check the mailing lists, I go with packages.

But, from what you did, you're not familiar with FreeBSD's ports tree: https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports.html, or if you're trying to make a custom or newer build, https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/.


----------



## zoujiaqing (Feb 7, 2018)

sidetone said:


> Building of Mozilla ports (Firefox, Thunderbird, NSS) has been problematic recently. If it doesn't work after I adjust the settings, and check the mailing lists, I go with packages.
> 
> But, from what you did, you're not familiar with FreeBSD's ports tree: https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports.html, or if you're trying to make a custom or newer build, https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/.


I want build nss without ports system.

How to do? thanks


----------



## MarcoB (Feb 7, 2018)

FreeBSD uses ports to build software. The port maintainer has ported nss to FreeBSD so that it builds and installs. What you want is what the maintainer already has done.


----------



## zoujiaqing (Feb 7, 2018)

MarcoB said:


> FreeBSD uses ports to build software. The port maintainer has ported nss to FreeBSD so that it builds and installs. What you want is what the maintainer already has done.


I used ports system's patch files.


----------



## rigoletto@ (Feb 7, 2018)

You would need to extract the tar file, patch the source manually, then manually make all other necessary changes in the source what are in the Makefile, compile, etc.

So, basically, a quite useless work since that is already done in the port. The people who would have anything actually useful doing that manually certain already know how to do that.


----------



## sidetone (Feb 7, 2018)

zoujiaqing said:


> I want build nss without ports system.
> 
> How to do? thanks


Use the second link (Porter's Handbook) to make a Makefile to build it how you want. Or if that's really not what you wanted, then proceed. The Porter's Handbook will help you either way, even if you want to totally avoid creating your custom makefile, and install everything from scratch.


----------



## zoujiaqing (Feb 8, 2018)

lebarondemerde said:


> You would need to extract the tar file, patch the source manually, then manually make all other necessary changes in the source what are in the Makefile, compile, etc.
> 
> So, basically, a quite useless work since that is already done in the port. The people who would have anything actually useful doing that manually certain already know how to do that.


thanks, I manual compiled like perl5/db5, but nss is failed.

I look ports Makefile(/usr/ports/security/nss/Makefile), I don't know it todo..


----------



## zoujiaqing (Feb 8, 2018)

sidetone said:


> Use the second link (Porter's Handbook) to make a Makefile to build it how you want. Or if that's really not what you wanted, then proceed. The Porter's Handbook will help you either way, even if you want to totally avoid creating your custom makefile, and install everything from scratch.


Yes, I'm reading this handbook, now.


----------



## rigoletto@ (Feb 8, 2018)

The most interesting part is the `post-patch` section, what basically is running sed(1) to adapt the source to FreeBSD; however it would be rather more efficient if you explain why you want to manually compile that. I mean what do you want made different, and then modify the port to do what you want.


----------



## ShelLuser (Feb 8, 2018)

Just see ports(7). Why not simply run `# make patch` in the ports directory, then go into the work directory (probably ./work/nss-3.35 at the time of writing) and then issue `# ./configure --help`, optionally `gmake`?


----------



## zoujiaqing (Feb 9, 2018)

lebarondemerde said:


> The most interesting part is the `post-patch` section, what basically is running sed(1) to adapt the source to FreeBSD; however it would be rather more efficient if you explain why you want to manually compile that. I mean what do you want made different, and then modify the port to do what you want.


Thanks!
I want to build custom firefox


----------



## zoujiaqing (Feb 9, 2018)

ShelLuser said:


> Just see ports(7). Why not simply run `# make patch` in the ports directory, then go into the work directory (probably ./work/nss-3.35 at the time of writing) and then issue `# ./configure --help`, optionally `gmake`?


Yes, I know use patch and gmake.
It not have configure and have Makefile ..


----------



## zoujiaqing (Feb 9, 2018)

Thanks everyone!

I'm compiled it!

I use this ENV:

```
export CC="clang -B/usr/local/bin"
gmake nss_build_all
```

Why use the -B parameter?!

O.M.G!


----------

