rui314 / mold

Mold: A Modern Linker 🦠
MIT License
14.42k stars 472 forks source link

How to invoke mold in compiling Chromium development versions? #198

Open DAC324 opened 2 years ago

DAC324 commented 2 years ago

Hello,

I just tried to replace ld.lld by mold in the chromium-dev AUR package. Looks like this is not possible as easy as described in the instructions. When ld.lld is replaced by /usr/bin/mold as per instructions, configure for chromium-dev fails:

/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/llvm-build/Release+Asserts/bin/clang is unable to create an executable file.
If /opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/llvm-build/Release+Asserts/bin/clang is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
Traceback (most recent call last):
  File "/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py", line 1081, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py", line 668, in main
    ConfigureAndBuild(
  File "/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py", line 1073, in ConfigureAndBuild
    do_build_ffmpeg('ChromeOS', chrome_os_flags)
  File "/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py", line 1050, in do_build_ffmpeg
    BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs,
  File "/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py", line 484, in BuildFFmpeg
    PrintAndCheckCall(
  File "/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py", line 120, in PrintAndCheckCall
    subprocess.check_call(argv, *args, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/ffmpeg/configure', '--disable-everything', '--disable-all', '--disable-doc', '--disable-htmlpages', '--disable-manpages', '--disable-podpages', '--disable-txtpages', '--disable-static', '--enable-avcodec', '--enable-avformat', '--enable-avutil', '--enable-fft', '--enable-rdft', '--enable-static', '--enable-libopus', '--disable-debug', '--disable-bzlib', '--disable-iconv', '--disable-lzo', '--disable-network', '--disable-schannel', '--disable-sdl2', '--disable-symver', '--disable-xlib', '--disable-zlib', '--disable-securetransport', '--disable-faan', '--disable-alsa', '--disable-autodetect', '--enable-decoder=vorbis,libopus,flac', '--enable-decoder=pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3', '--enable-decoder=pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw', '--enable-demuxer=ogg,matroska,wav,flac,mp3,mov', '--enable-parser=opus,vorbis,flac,mpegaudio,vp9', '--extra-cflags=-I/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/opus/src/include', '--disable-linux-perf', '--x86asmexe=nasm', '--optflags="-O2"', '--enable-decoder=theora,vp8', '--enable-parser=vp3,vp8', '--enable-lto', '--enable-pic', '--cc=clang', '--cxx=clang++', '--ld=clang', '--extra-ldflags=-fuse-ld=/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/llvm-build/Release+Asserts/bin//usr/bin/mold', '--enable-decoder=aac,h264', '--enable-demuxer=aac', '--enable-parser=aac,h264', '--enable-decoder=mpeg4', '--enable-parser=h263,mpeg4video', '--enable-demuxer=avi', '--enable-demuxer=amr', '--enable-decoder=amrnb,amrwb', '--enable-decoder=gsm_ms', '--enable-parser=gsm', '--disable-lto', '--cc=/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/llvm-build/Release+Asserts/bin/clang', '--cxx=/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/llvm-build/Release+Asserts/bin/clang++', '--ld=/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/llvm-build/Release+Asserts/bin/clang', '--ar=/opt/.cache/yay/chromium-dev/src/chromium-99.0.4789.0/third_party/llvm-build/Release+Asserts/bin/llvm-ar']' returned non-zero exit status 1.

So it looks like simply replacing ld.lld by mold is not enough. Perhaps there are additional configuration steps necessary.

rui314 commented 2 years ago

How did you actually replace ld.lld with mold? As far as I know, chromium repo contains its original copy of ld.lld. Did you overwrite it?

DAC324 commented 2 years ago

There's an internal variable _lld in the PKGBUILD that is simply set to "ld.lld" and its contents is passed to the -fuse option when calling clang. I simply tried replacing the "ld.lld" entry there so that clang is called with -fuse="/usr/bin/mold" instead of -fuse="ld.lld" but for some unknown reason, that doesn't work.

Am 26. Dezember 2021 12:12:32 schrieb Rui Ueyama @.***>:

How did you actually replace ld.lld with mold? As far as I know, chromium repo contains its original copy of ld.lld. Did you overwrite it? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

ptr1337 commented 2 years ago

There's an internal variable _lld in the PKGBUILD that is simply set to "lld.ld" and its contents is passed to the -fuse option when calling clang. I simply tried replacing the "lld.ld" entry there so that clang is called with -fuse="/usr/bin/mold" instead of -fuse="lld.ld" but for some unknown reason, that doesn't work. Am 26. Dezember 2021 12:12:32 schrieb Rui Ueyama @.>: How did you actually replace ld.lld with mold? As far as I know, chromium repo contains its original copy of ld.lld. Did you overwrite it? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.>

I will maybe try later also a build. Maybe also check this line: There are two lines regarding the linker: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=chromium-dev#n476 https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=chromium-dev#n572

The only problem i see, if there is anything built with lto, it will issue the build. I will let you know.

Edit:

Also we should watch the patches about any changes are done regarding linking/ltoing ?

And one more thing: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=chromium-dev#n610

DAC324 commented 2 years ago

There's an internal variable lld in the PKGBUILD that is simply set to "ld.lld" and its contents is passed to the -fuse option when calling clang. I simply tried replacing the "ld.lld" entry there so that clang is called with -fuse="/usr/bin/mold" instead of -fuse="ld.lld" but for some unknown reason, that doesn't work. Am 26. Dezember 2021 12:12:32 schrieb Rui Ueyama @.>: How did you actually replace ld.lld with mold? As far as I know, chromium repo contains its original copy of ld.lld. Did you overwrite it? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: _@_._>

I will maybe try later also a build. Maybe also check this line: There are two lines regarding the linker: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=chromium-dev#n476 https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=chromium-dev#n572

Indeed, these two lines appear to be connected to each other. If I am not mistaken, it should be sufficient to replace _lld="ld.lld" with _lld="/usr/bin/mold" in line 476, and the contents of this variable is then inserted via the sed command in the build files.

The only problem i see, if there is anything built with lto, it will issue the build. I will let you know.

Edit:

Also we should watch the patches about any changes are done regarding linking/ltoing ?

And one more thing: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=chromium-dev#n610

Yes, I saw that as well but did not understand why clang is apparently chosen as a linker here. Finally, I didn't want to cause any inconvenience - I just saw the example GIF which refers to Chromium, and hence, I was wondering how I could use mold in the AUR package as well.

Kind regards, DAC324

ptr1337 commented 2 years ago

Alright, thanks. Sincee for chromium based browsers, if compiling them much (often), like me at a repo, the linker couldd definitly help.

Can you post me here the link? Would it possible to do for ungoogled-chromium also one?

Regards.

DAC324 commented 2 years ago

Sincee for chromium based browsers, if compiling them much (often), like me at a repo, the linker couldd definitly help.

Can you post me here the link? Would it possible to do for ungoogled-chromium also one?

At first, I use https://gsdview.appspot.com/chromium-browser-official/?marker=chromium-99.0.4789.0-testdata.tar.x%40 to see which version is the latest with available sources.

Then, I use the chromium-dev AUR package at https://aur.archlinux.org/packages/chromium-dev/, editing PKGBUILD to use the latest version identified in the first link. There is the pkgver variable at the very beginning of PKGBUILD where you can enter the chromium version you want to build.

For ungoogled-chromium, I'd strongly recommend using the version proposed in PKGBUILD as this package does heavily patching and all the patches are carefully tweaked to work with that particular version. You can find ungoogled-chromium at https://aur.archlinux.org/packages/ungoogled-chromium/

Kind regards, DAC324

ptr1337 commented 2 years ago

@DAC324 Yes, i know how a PKGBUILD works. I just when you got it working with mold to run that, that you can post the PKGBUILD.

Regards.

DAC324 commented 2 years ago

Meanwhile, the chromium developers have clearly committed themselves to not support building chromium with mold: https://bugs.chromium.org/p/chromium/issues/detail?id=1280356#c1

Apparently as a consequence, they are now blocking mold as with the latest (as of today) chromium development version 104.0.5099.0, it is not possible to get a working flatc binary anymore:

flatc: malloc.c:4302: _int_malloc: Assertion `(unsigned long) (size) >= (unsigned long) (nb)' failed.

Thus, all flatc calls during the build process fail, and chromium cannot be built.

ishitatsuyuki commented 2 years ago

Is it about the same topic as #336? If so, I would like to close this in favor of that issue.