bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#45934: native-comp - Dylib ID of ELN files not optimal


From: Davide Restivo
Subject: bug#45934: native-comp - Dylib ID of ELN files not optimal
Date: Sun, 17 Jan 2021 17:48:00 +0100

Hi Andrea,

A dylib (extension .dylib) is the same as a GNU/Linux shared object (extension 
.so). Please find below the requested output:

```
$ /usr/local/bin/gcc-10 --version
gcc-10 (Homebrew GCC 10.2.0_2) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ /usr/local/bin/gcc-10 -v -dynamiclib Ratings.c -install_name 
/usr/lib/ratings.dylib -o ratings.dylib
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc-10
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin19/10.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../configure --build=x86_64-apple-darwin19 
--prefix=/usr/local/Cellar/gcc/10.2.0_2 
--libdir=/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10 --disable-nls 
--enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran 
--program-suffix=-10 --with-gmp=/usr/local/opt/gmp 
--with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc 
--with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew 
GCC 10.2.0_2' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues 
--disable-multilib --with-native-system-header-dir=/usr/include 
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk 
SED=/usr/bin/sed
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (Homebrew GCC 10.2.0_2)
COLLECT_GCC_OPTIONS='-v' '-Zdynamiclib' '-Zinstall_name' 
'/usr/lib/ratings.dylib' '-o' 'ratings.dylib' '-mmacosx-version-min=10.15.0' 
'-asm_macosx_version_min=10.15' '-mtune=core2'
 /usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin19/10.2.0/cc1 
-quiet -v -D__DYNAMIC__ Ratings.c -fPIC -quiet -dumpbase Ratings.c 
-mmacosx-version-min=10.15.0 -mtune=core2 -auxbase Ratings -version -o 
/var/folders/r4/5c0t6dm912vggdd3jbjf_3tr0000gn/T//ccN17V5Q.s
GNU C17 (Homebrew GCC 10.2.0_2) version 10.2.0 (x86_64-apple-darwin19)
        compiled by GNU C version 10.2.0, GMP version 6.2.1, MPFR version 
4.1.0, MPC version 1.2.1, isl version isl-0.23-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory 
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/local/include"
ignoring nonexistent directory 
"/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/../../../../../../x86_64-apple-darwin19/include"
ignoring nonexistent directory 
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 
/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/include
 
/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/include-fixed
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
 
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks
End of search list.
GNU C17 (Homebrew GCC 10.2.0_2) version 10.2.0 (x86_64-apple-darwin19)
        compiled by GNU C version 10.2.0, GMP version 6.2.1, MPFR version 
4.1.0, MPC version 1.2.1, isl version isl-0.23-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 966ca361396c29aa9c1bedc558ef6a08
COLLECT_GCC_OPTIONS='-v' '-Zdynamiclib' '-Zinstall_name' 
'/usr/lib/ratings.dylib' '-o' 'ratings.dylib' '-mmacosx-version-min=10.15.0'  
'-mtune=core2'
 as -arch x86_64 -v -force_cpusubtype_ALL -mmacosx-version-min=10.15 -o 
/var/folders/r4/5c0t6dm912vggdd3jbjf_3tr0000gn/T//cccaMqmZ.o 
/var/folders/r4/5c0t6dm912vggdd3jbjf_3tr0000gn/T//ccN17V5Q.s
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
 -cc1as -triple x86_64-apple-macosx10.15.0 -filetype obj -main-file-name 
ccN17V5Q.s -target-cpu penryn -fdebug-compilation-dir /Users/gutter/Downloads 
-dwarf-debug-producer "Apple clang version 12.0.0 (clang-1200.0.32.28)" 
-dwarf-version=4 -mrelocation-model pic -o 
/var/folders/r4/5c0t6dm912vggdd3jbjf_3tr0000gn/T//cccaMqmZ.o 
/var/folders/r4/5c0t6dm912vggdd3jbjf_3tr0000gn/T//ccN17V5Q.s
COMPILER_PATH=/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin19/10.2.0/:/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin19/10.2.0/:/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin19/:/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/:/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/
LIBRARY_PATH=/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/:/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-Zdynamiclib' '-Zinstall_name' 
'/usr/lib/ratings.dylib' '-o' 'ratings.dylib' '-mmacosx-version-min=10.15.0'  
'-mtune=core2'
 
/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin19/10.2.0/collect2
 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/ -dynamic 
-dylib -arch x86_64 -dylib_install_name /usr/lib/ratings.dylib 
-macosx_version_min 10.15.0 -weak_reference_mismatches non-weak -o 
ratings.dylib 
-L/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0 
-L/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/../../..
 /var/folders/r4/5c0t6dm912vggdd3jbjf_3tr0000gn/T//cccaMqmZ.o -lSystem 
-lgcc_ext.10.5 -lgcc -lSystem -no_compact_unwind -v
collect2 version 10.2.0
/usr/bin/ld -syslibroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/ -dynamic -dylib -arch 
x86_64 -dylib_install_name /usr/lib/ratings.dylib -macosx_version_min 10.15.0 
-weak_reference_mismatches non-weak -o ratings.dylib 
-L/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0 
-L/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/../../..
 /var/folders/r4/5c0t6dm912vggdd3jbjf_3tr0000gn/T//cccaMqmZ.o -lSystem 
-lgcc_ext.10.5 -lgcc -lSystem -no_compact_unwind -v
@(#)PROGRAM:ld  PROJECT:ld64-609.8
BUILD 20:09:52 Nov  4 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 
x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
        
/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0
        /usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10
        /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib
Framework search paths:
        
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/
ld: warning: static initializer found in 
'/var/folders/r4/5c0t6dm912vggdd3jbjf_3tr0000gn/T//cccaMqmZ.o'. Use -no_inits 
to make this an error.  Use -no_warn_inits to suppress warning
ld: warning: invalid -install_name (/usr/local/lib/gcc/10/libgcc_s.1.dylib) in 
dependent dylib 
(/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/libgcc_ext.10.5.dylib). 
Dylibs/frameworks which might go in dyld shared cache cannot link with dylibs 
that won't be in the shared cache
ld: warning: linking with (/usr/local/lib/gcc/10/libgcc_s.1.dylib) but not 
using any symbols from it
```

Now we can verify using otool that the dylib ID is correctly set:

```
$ otool
Usage: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool
 [-arch arch_type] [-fahlLDtdorSTMRIHGvVcXmqQjCP] [-mcpu=arg] [--version] 
<object file> ...
        -f print the fat headers
        -a print the archive header
        -h print the mach header
        -l print the load commands
        -L print shared libraries used
        -D print shared library id name.                          <—— This 
option is used to print the dylib ID
        -t print the text section (disassemble with -v)
        -x print all text sections (disassemble with -v)
        -p <routine name>  start dissassemble from routine name
        -s <segname> <sectname> print contents of section
        -d print the data section
        -o print the Objective-C segment
        -r print the relocation entries
        -S print the table of contents of a library (obsolete)
        -T print the table of contents of a dynamic shared library (obsolete)
        -M print the module table of a dynamic shared library (obsolete)
        -R print the reference table of a dynamic shared library (obsolete)
        -I print the indirect symbol table
        -H print the two-level hints table (obsolete)
        -G print the data in code table
        -v print verbosely (symbolically) when possible
        -V print disassembled operands symbolically
        -c print argument strings of a core file
        -X print no leading addresses or headers
        -m don't use archive(member) syntax
        -B force Thumb disassembly (ARM objects only)
        -q use llvm's disassembler (the default)
        -Q use otool(1)'s disassembler
        -mcpu=arg use `arg' as the cpu for disassembly
        -j print opcode bytes
        -P print the info plist section as strings
        -C print linker optimization hints
        --version print the version of 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool
```

The dylib ID is correctly set:

```
$ otool -D ratings.dylib
ratings.dylib:
/usr/lib/ratings.dylib
```

Thanks for the help,
Davide


> On 17 Jan 2021, at 13:36, akrl--- via Bug reports for GNU Emacs, the Swiss 
> army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
> 
> "davide.restivo--- via \"Bug reports for GNU Emacs, the Swiss army knife
> of text editors\"" <bug-gnu-emacs@gnu.org> writes:
> 
> [...]
> 
>> Since the tmp directory is stripped out and replaced with the
>> destination directory, as you can see, all of the ELN files ends up with
>> the same dylib ID, and this is not allowed on macOS. My suggestion here
>> would be to add the 'install_name' [2] flag to gcc during the ELN files
>> compilation replacing the 'fake.so' with the original .eln filename.
>> 
>> Thanks and regards,
>> Davide
>> 
>> 
>> [1] https://github.com/daviderestivo/homebrew-emacs-head
>> [2] gcc -o libdummy.dylib -install_name ${PREFIX}/lib/libdummy.dylib 
> 
> Hi Davide,
> 
> I'm really ignorant on MacOS so I'll comment for what I can.  I had a
> look to the GCC doc [1] but I could not figure out if '-install_name' is
> an option that goes to the compiler or the linker (nor I know what this
> dylib ID exactly is).  If the flag is routed to the linker we should be
> able to add it but only when libgccjit >= 9 is used.
> 
> Could you run a random compilation of something using '-install_name'
> but adding also '-v' and report the console output so we can see where
> the driver is routing the flag?
> 
> Thanks
> 
>  Andrea
> 
> [1] https://gcc.gnu.org/onlinedocs/gcc/Darwin-Options.html
> 
> 
> 





reply via email to

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