[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building Emacs on MacOS with clang+LTO fails

From: Paul Eggert
Subject: Re: Building Emacs on MacOS with clang+LTO fails
Date: Sat, 4 May 2019 13:21:09 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

dhruva wrote:
I am trying to build emacs using clang 8 (from home-brew) with link time
optimization enabled.

As INSTALL says, link time optimization seems to make Emacs slower and/or crashier even when Emacs builds. Plus as you've discovered, Emacs tends not to build. So I don't recommend LTO unless your job is to fix LTO bugs.

Emacs configured as:
LD=lld CC=clang CFLAGS="-flto" ../../git/emacs/configure --with-mailutils

I don't think LD matters.

I suggest using the --enable-link-time-optimization flag of 'configure' instead.

For what it's worth, I just now tried building Emacs master on Fedora 30 as 

./configure --enable-link-time-optimization CC=clang

and found a recently-introduced bug with fingerprinting that is a different bug from your problem. I installed the attached patch to work around it. As this patch suggests, LTO is not often tested with Emacs.

   CCLD     make-fingerprint
ld: reference to bitcode symbol '_rpl_getopt' which LTO has not compiled in
'_main' from /var/folders/5c/5w9bqxts6gl2pgfgdpzq94n0nhqj5f/T/cc-ebc71c.o
for architecture x86_64
clang-8: error: linker command failed with exit code 1 (use -v to see

If make-fingerprint links without LTO and fails to link with LTO, it's most likely a bug in the way Emacs is using the linker (or a bug in the compiler or linker), which surely would need to be investigated further on your platform.

-  while (0 <= (c = getopt (argc, argv, "rh")))
+  while (0 <= (c = getopt_long (argc, argv, "rh", NULL, NULL)))

This doesn't look right, for a couple of reasons. First, getopt_long doesn't document what it does wit a null 4th arg. More importantly, why is this change needed, and not similar changes in other getopt calls? It'd be better to debug the actual linking problem than to try to paper over it.

Attachment: 0001-Port-new-fingerprinting-scheme-to-clang-LTO.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]