Build failures (Gentoo, probably PIE/PIC related) Topic is solved

Users and developers helping users with generic and technical Pale Moon issues on all operating systems.

Moderator: trava90

Forum rules
This board is for technical/general usage questions and troubleshooting for the Pale Moon browser only.
Technical issues and questions not related to the Pale Moon browser should be posted in other boards!
Please keep off-topic and general discussion out of this board, thank you!
eliddell

Build failures (Gentoo, probably PIE/PIC related)

Unread post by eliddell » 2017-12-29, 21:30

I have been trying to build palemoon on a new machine (Threadripper 1900X) using the ebuilds from the palemoon overlay. Since the system was installed within the last week or so, it's using the 17.0 system profiles with default PIE.

Every build I've attempted has failed in the same place:

Code: Select all

6:35.90     INPUT("../../gfx/skia/Unified_cpp_gfx_skia7.o")
 6:35.90     INPUT("../../gfx/skia/Unified_cpp_gfx_skia8.o")
 6:35.90     INPUT("../../gfx/skia/Unified_cpp_gfx_skia9.o")
 6:35.90     INPUT("StaticXULComponentsEnd/StaticXULComponentsEnd.o")
 6:35.90 
 6:35.90 ../../build/unix/gold/ld: error: /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/o/toolkit/library/../../media/libstagefright/Unified_cpp_media_libstagefright0.o: requires dynamic R_X86_64_PC32 reloc against '_Z13GetDemuxerLogv' which may overflow at runtime; recompile with -fPIC
 6:35.90 ../../build/unix/gold/ld: error: read-only segment has dynamic relocations
 6:35.90 /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp:728: error: undefined reference to 'GetDemuxerLog()'
 6:35.90 /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp:735: error: undefined reference to 'GetDemuxerLog()'
 6:35.90 /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp:591: error: undefined reference to 'GetDemuxerLog()'
 6:35.90 /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp:599: error: undefined reference to 'GetDemuxerLog()'
 6:35.90 collect2: error: ld returned 1 exit status
 6:35.90 gmake[5]: *** [/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/config/rules.mk:820: libxul.so] Error 1
 6:35.90 gmake[4]: *** [/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/config/recurse.mk:74: toolkit/library/target] Error 2
 6:35.90 gmake[3]: *** [/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/config/recurse.mk:37: compile] Error 2
 6:35.90 gmake[2]: *** [/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/config/rules.mk:541: default] Error 2
 6:35.90 gmake[1]: *** [/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/client.mk:399: realbuild] Error 2
 6:35.90 gmake: *** [client.mk:171: build] Error 2
I have tried both the current stable gcc (6.4.0) and the recommended 4.9.4. I've also tried a slightly older Palemoon version (27.5.1), which built correctly on my previous system (still Gentoo, gcc 5.4.0, profile 13.0, not PIE), and various combinations of USE flags.

The most infuriating part of this is that I neither need nor want media support in my primary browser (its absence cuts down massively on timewasting, security exploits, and crash bugs), so for all of me, libstagefright and everything associated with it can die in a fire.

Is there another ebuild I can use that actually works? Alternatively, is there a way I can kill libstagefright with extreme prejudice, or some other way I can patch my way past this bug?

testator777

Re: Build failures (Gentoo, probably PIE/PIC related)

Unread post by testator777 » 2017-12-30, 04:09

Errors like what you are seeing are the poorer parts of the code quality in the program. The fix is, assuming you have layman setup and installed:

Code: Select all

localhost ~ # layman -a mv
localhost ~ # emerge portage-bashrc-mv
This overlay and ebuild allow you to change cflags and override default package forced cflags by using the directory /etc/portage/package.cflags/*insert file here*. Read the docs on it for how to use it as you can do much more with it. But generally you want in a file such as /etc/portage/package.cflags/all-systems

Code: Select all

www-client/palemoon +D*FILE* +*math* +fno-common +fmerge-all-constants +finline-functions +fdirectives-only +flto-partition* +flto* +fPIE +pie
Palemoon doesn't play/compile nicely with lto, the GNU gold linker, and pie/pic as of 27.6.2. If you used 27.6.0 you could get LTO to work properly though. You can use -O3 and gcc 7.2.0 safely with both ebuilds. You may also want to edit the palemoon ebuild to use system libraries more for things like png and jpeg viewer libraries.

Walter Dnes
Astronaut
Astronaut
Posts: 650
Joined: 2015-07-30, 20:29
Location: Vaughan, ON, Canada

Re: Build failures (Gentoo, probably PIE/PIC related)

Unread post by Walter Dnes » 2017-12-30, 05:39

The answer is right there in the error message...
eliddell wrote: 6:35.90 ../../build/unix/gold/ld: error: /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/o/toolkit/library/../../media/libstagefright/Unified_cpp_media_libstagefright0.o: requires dynamic R_X86_64_PC32 reloc against '_Z13GetDemuxerLogv' which may overflow at runtime; recompile with -fPIC
It comes down to matching position (in)dependant code and executables. If you select "-fpie" flag you must also select "-fPIC" flag, and have USE="pic" (Note that the minus sign has different meaning in CFLAGS/CXXFLAGS versus USE.)

I disagree with the previous post. -O3 is NOT recommended. It causes problems for many packages, and you won't get support on the Gentoo forums if you implement -O3. System libs are also not recommended for Pale Moon. I don't know enough about the other optimizations to comment on them.
There's a right way
There's a wrong way
And then there's my way

eliddell

Re: Build failures (Gentoo, probably PIE/PIC related)

Unread post by eliddell » 2017-12-30, 23:52

I'm still getting the same error in the same place (except with a few combinations of CFLAGS, USE, etc., where it hangs up a little earlier on sqlite instead).

The last real command before the failure indicates that -fPIC is being passed (between -fomit-frame-pointer and -shared), and the error makes it look like a bundled library is being built without it, so something's fishy there::

Code: Select all

Executing: c++ -Wall -Wempty-body -Woverloaded-virtual -Wsign-compare -Wwrite-strings -Wno-invalid-offsetof -Wcast-align -pipe -march=native -fno-exceptions -fno-strict-aliasing -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2 -fno-rtti -fno-exceptions -fno-math-errno -std=gnu++0x -pthread -pipe -DNDEBUG -DTRIMMED -g -O2 -msse2 -mfpmath=sse -fomit-frame-pointer -fPIC -shared -Wl,-z,defs -Wl,-h,libxul.so -o libxul.so /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/o/toolkit/library/tmpfx9KGG.list -lpthread -Wl,-O1 -Wl,--as-needed -Wl,-rpath=/usr/lib64/palemoon -Wl,-z,noexecstack -Wl,-z,text -Wl,--build-id -B ../../build/unix/gold -Wl,-version-script,symverscript -Wl,-rpath-link,/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/o/dist/bin -Wl,-rpath-link,/usr/local/lib ../../security/nss/lib/crmf/libcrmf.a ../../js/src/libjs_static.a ../../intl/icu/target/lib/libicui18n.a ../../intl/icu/target/lib/libicuuc.a ../../intl/icu/target/lib/libicudata.a ../../security/nss/lib/nss/libnss3.so ../../security/nss/lib/smime/libsmime3.so ../../security/nss/lib/ssl/libssl3.so ../../security/nss/lib/util/libnssutil3.so ../../nsprpub/lib/ds/libplds4.so ../../nsprpub/lib/libc/src/libplc4.so ../../nsprpub/pr/src/libnspr4.so ../../memory/mozalloc/libmozalloc.so -ldl -lsqlite3 -lm -ldl -lfreetype -lfontconfig -lrt -lXrender -lasound -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lfontconfig -lfreetype -lgdk-x11-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lX11 -lXext -lpangoft2-1.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lXt -lgthread-2.0
Things I've tried:
  • testator777's advice
  • forcing a different linker using -fuse-ld in CFLAGS (I still don't know why it's showing such a preference for gold over ld, since I certainly didn't tell it to)
  • passing "-fPIC -fpic -fPIE -fpie" and various subsets in CFLAGS
  • doing various things to the LDFLAGS (all failed)
  • emerge --emptytree palemoon (the entire system should have been built with PIC/PIE active, as it's default for the profile, but I figured I'd make sure absolutely nothing had been missed). Everything built except Pale Moon.
Does anyone have any other ideas, or should I just give up at this point and go with the prebuilt version, even though it isn't my preference?

testator777

Re: Build failures (Gentoo, probably PIE/PIC related)

Unread post by testator777 » 2017-12-31, 03:11

You can't use PIC or PIE with palemoon, it won't ever compile unless you want to debug the errors and fix it yourself and possibly submit a patch to moonchild upstream. Remove all the PIC and PIE flags like so in /etc/portage/package.cflags/all-systems

Code: Select all

www-client/palemoon +D*FILE* +*math* +fno-common +fmerge-all-constants +finline-functions +fdirectives-only +flto-partition* +flto* +fPIE +pie +fPIC -fuse-ld=bfd
Last edited by testator777 on 2017-12-31, 03:17, edited 2 times in total.

eliddell

Re: Build failures (Gentoo, probably PIE/PIC related)

Unread post by eliddell » 2017-12-31, 22:07

Conclusion, after wrestling with this some more: PIC is refusing to turn off. portage-bashrc-mv isn't cancelling the flag. No idea why.

I could move on to trying to mangle cflags inside the ebuild, but I don't have the patience right now, so I'll install the prebuilt binary instead and drop this for a while.

s014377

Re: Build failures (Gentoo, probably PIE/PIC related)

Unread post by s014377 » 2018-02-04, 08:20

i just ran into the exact same problem when emerging palemoon-27.7.2.
turns out that this happens when the 'ffmpeg' useflag is missing. (i think the ffmpeg useflag is new since the palemoon-27.6.2 ebuild)
i have no idea how/why this causes that error. but it seems there is a bug in the ebuild or the build-process.

here are the useflags i used for building palemoon-27.7.2:

Code: Select all

USE="dbus devtools ffmpeg gtk2 official-branding optimize pulseaudio threads -alsa -debug (-gtk3) -jemalloc -necko-wifi -shared-js -system-bzip2 -system-libevent -system-libvpx -system-libwebp -system-sqlite -system-zlib -valgrind -webrtc"

Locked