# Firefox compilation errors under FreeBSD 9.3



## apolinsky (Jan 15, 2015)

I noticed a security message last night so I decided to upgrade Firefox on both my 9.3 and 10.1 machines. The 10.1 compiled cleanly and installed without problems while the 9.3 gave me the following error:


```
In file included from /usr/ports/www/firefox/work/mozilla-release/obj-i387-portbld-freebsd9.3/content/media/Unified_cpp_content_media1.cpp:29:
/usr/ports/www/firefox/work/mozilla-release/content/media/MediaDecoderStateMachine.cpp:1315:7: error:
  call to 'abs' is ambiguous
  std::abs(aDuration - duration) > ESTIMATED_DURATION_FUZZ_FACTOR...
/usr/include/stdlib.h:83:6: note: candidate function
int  abs(int) __pure2;
  ^
/usr/include/c++/4.2/cmath:89:3: note: candidate function
  abs(double __x)
  ^
/usr/include/c++/4.2/cmath:93:3: note: candidate function
  abs(float __x)
  ^
/usr/include/c++/4.2/cmath:97:3: note: candidate function
  abs(long double __x)
  ^
/usr/include/c++/4.2/cstdlib:143:3: note: candidate function
  abs(long __i) { return labs(__i); }
  ^
1 error generated.
/usr/ports/www/firefox/work/mozilla-release/config/rules.mk:948: recipe for target 'Unified_cpp_content_media1.o' failed
gmake[5]: *** [Unified_cpp_content_media1.o] Error 1
```

Can someone suggest what caused the error?

Thank you.


----------



## talsamon (Jan 15, 2015)

Try to compile it with the gcc. `make install clean CC=gcc48 CXX=g++48 CPP=cpp48`.


----------



## apolinsky (Jan 15, 2015)

I have just restarted compilation with your suggestion. I'll report back if there are problems. In order to promote my understanding, could you explain the successful compilation on my FreeBSD 10 machine while there was a failure on the 9.3?

Alan


----------



## talsamon (Jan 15, 2015)

In the moment I have no 9.3 to test it. I hope it will work. This error normally appears if math.h and cmath.h  both included. Maybe `clang` had problems with the namespace, but I can't tell it surely.


----------



## pkubaj (Jan 15, 2015)

It may be related to 10.0+ using libc++ and 9.1-9.3 using libstdc++ by default (it's possible to use libc++ in 9.1-9.3).


----------



## apolinsky (Jan 15, 2015)

If I wanted to try out that suggestion of using libc++ with clang in my 9.3 instance, how would I do that?


----------



## wblock@ (Jan 15, 2015)

Always try the easy stuff first: turn off the various optimizations like OPTIMIZED_CFLAGS and PGO.


----------



## apolinsky (Jan 15, 2015)

I must admit that before I tried switching to gcc, I was going to turn off the optimized_cflags option, since I had read about problems with it and clang, but that's when the suggestion of gcc came in. Thank you to everyone for all of your suggestions. Being a recently retired programmer, which significant experience on Sun computers, I've learned to ask questions when I need help, but only after trying some alternatives on my own.

Alan


----------



## pkubaj (Jan 15, 2015)

See http://blogs.freebsdish.org/theraven/2013/01/03/the-new-c-stack-in-9-1/


----------



## apolinsky (Jan 17, 2015)

Just a bit update on my lack of success so far. I initially tried to switch to gcc using the switches that were suggested. That failed. I turned off all optimizations, and retried both gcc and clang, receiving failures each time. I did check the compiler for which the code was produced, and using the make -V for CC, CXX,and CPP indicated clang. I am tending to think (or at least hope) that the above suggestion with switching to the new stack will help. I have compiled and installed the new stack but am a bit confused as to how to invoke it either with a 'make' of Firefox, or a 'portupgrade'. Can someone suggest the proper syntax?

Thank you.

Alan


----------



## pkubaj (Jan 17, 2015)

Add 

```
CXXFLAGS= -stdlib=libc++ -std=c++11
LDFLAGS= -stdlib=libc++
```
to /etc/make.conf.


----------



## apolinsky (Jan 17, 2015)

Unfortunately, when I tried implementing the new stack I still get an error though this time it is:


```
Executing: clang++ -o host_jskwgen -Qunused-arguments -isystem/usr/local/include -Qunused-arguments -Wall -Wignored-qualifiers -Wsign-compare -Wtype-limits -Werror=char-subscripts -Werror=comment -Werror=empty-body -Werror=endif-labels -Werror=int-to-pointer-cast -Werror=missing-braces -Werror=overloaded-virtual -Werror=pointer-arith -Werror=reorder -Werror=return-type -Werror=sequence-point -Werror=switch -Werror=trigraphs -Werror=unknown-pragmas -Werror=unused-label -Werror=unused-value -Werror=write-strings -Werror=conversion-null -Wno-invalid-offsetof -Wno-c++0x-extensions -Wno-extended-offsetof -Wno-unknown-warning-option -Wno-return-type-c-linkage -stdlib=libc++ -std=c++11 -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -std=gnu++0x -pipe -DNDEBUG -DTRIMMED -fno-omit-frame-pointer -std=gnu++0x -MD -MP -MF .deps/host_jskwgen.pp -I/usr/ports/www/firefox/work/mozilla-release/js/src -I. -I/usr/local/lib/libffi-3.2.1/include -I/usr/local/include -I../../dist/include host_jskwgen.o
/usr/lib/libcxxrt.so: undefined reference to `__sync_val_compare_and_swap_8'
/usr/lib/libcxxrt.so: undefined reference to `__sync_bool_compare_and_swap_8'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
/usr/ports/www/firefox/work/mozilla-release/config/rules.mk:767: recipe for target 'host_jskwgen' failed
gmake[5]: *** [host_jskwgen] Error 1
```

Alan


----------



## protocelt (Jan 17, 2015)

If you're running 9.3-RELEASE *i386*, there is a PR 196772 for this with what seems to be a working patch attached. You can apply the patch yourself and rebuild the port or wait for the port to be updated which I would think should be soon.


----------



## apolinsky (Jan 17, 2015)

That must be the answer. I'm running 9.3 on one machine and 10.1 on the other. The help I've gotten from everyone in this thread has been immeasurable in increasing my knowledge of FreeBSD. It reminds me of the time when one of my staff members was able to bring down a large Sun machine that supports critical tasks for New York City, because an application of his put various extracted files on /tmp. I don't remember the release of Solaris we were using but think it was in the 10 series. In that release, and possibly to date, /tmp and Swap are the same partition. His files completely filled that partition and brought the machine to a halt. He moved all the files to /var/tmp which cured the problem.

Alan


----------



## talsamon (Jan 18, 2015)

Now, I try it on 9.3. Firefox compiles fine for me. Maybe, the error is caused by the `optimized_cflags option` ?


----------



## apolinsky (Jan 21, 2015)

I have just successfully compiled the patched version of Firefox. I will admit I shied away from trying to patch the code myself, and waited until the patched source appeared in the ports. Is there a way to thank the user going under the tag of 'woot-woot' who was the first person to correctly identify and patch the problem I was experiencing? I don't know if that is Barbara Guida who's name I notice in the initial write up of the bug. Thank you to everyone for the help.

Alan


----------

