I attached a first version of a patch to fix that. After building with this patch, the firefox binary is reported as PIE by otool -hv.
Before adding wrappers for clang and clang++ adding the -fPIE option, I first tried to add it to the CFLAGS variable in .mozconfig-mac, but this makes the build fail with this error:
I think ideally I'd like to have all necessary changes in one place and not split into different repos (especially if it is only about setting the proper compiler/linker flags). I am not sure, though, I understand yet why your first try is failing while the second succeeds. Thus, it is a bit hard to make a good case for e.g. putting everything into .mozconfig-mac. That said, if missing PIE affects other components as well (tor comes to mind here) we might indeed want to think about a more general, non-mozconfig solution anyway...
I think ideally I'd like to have all necessary changes in one place and not split into different repos (especially if it is only about setting the proper compiler/linker flags).
I am not sure, though, I understand yet why your first try is failing while the second succeeds.
I am not completely sure either, but it looks like libtool in js/src/ctypes/libffi is parsing the arguments to find the type of command it is running, and having -fPIE in the arguments makes it fail. I think the second succeeds because -fPIE is not in the list of arguments in this case.
A better fix might be to patch libffi to use the --tag= options when calling libtool. I will try that.
Thus, it is a bit hard to make a good case for e.g. putting everything into .mozconfig-mac. That said, if missing PIE affects other components as well (tor comes to mind here) we might indeed want to think about a more general, non-mozconfig solution anyway...
tor is not affected, I think because the configure.ac is adding the -fPIE and -pie flags. The pluggable transports are not PIE, but they are not built using llvm. So the only component affected by this at the moment seems to be firefox.
FWIW: I'd rather be happy to have some kind of patch for the next alpha than nothing. Thus, if we don't get to the bottom of the problem let's go with the wrapper for now.
tor-browser-0001-Bug-20439-make-the-build-PIE-on-OSX.patch is a patch for tor-browser.git adding -Wl,-pie to LDFLAGS.
tor-browser-bundle-0001-Bug-20439-make-the-build-PIE-on-OSX.patch is a patch for builders/tor-browser-bundle.git creating wrappers on clang and clang++ to add the -fPIE flag.
Trac: Keywords: N/Adeleted, TorBrowserTeam201611R added Status: new to needs_review
Looks good to me. One nit: I added a fixup! rule for the .mozconfig-mac patch (in case you were wondering). This is on tor-browser-bundle master commit 565f2cc6e5c8e496bc50f03defa98947e24c93c4 and on tor-browser-45.4.0esr-6.5-1 db846f717b90c587b1934c65dd973e0ba0f14acd.
Trac: Status: needs_review to closed Resolution: N/Ato fixed