jonls / redshift

Redshift adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night.
http://jonls.dk/redshift
GNU General Public License v3.0
5.82k stars 425 forks source link

Link errors when compiling with Clang (with any of GNU ld, lld, 1.12, Git master) #802

Open hartwork opened 3 years ago

hartwork commented 3 years ago

Describe the bug When compiling with Clang, I get link errors like this one:

/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: colorramp.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE

This happens with linker GNU ld but also with linker lld. This applies to both latest release 1.12 as well as Git master of today.

To Reproduce

# cd "$(mktemp -d)"
# git clone --depth 1 https://github.com/jonls/redshift
# cd redshift/
# ./bootstrap
# CC=clang ./configure && make
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking whether clang understands -c and -o together... yes
checking dependency style of clang... gcc3
checking for clang option to accept ISO C99... none needed
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by clang... /usr/bin/x86_64-pc-linux-gnu-ld
checking if the linker (/usr/bin/x86_64-pc-linux-gnu-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/x86_64-pc-linux-gnu-ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from clang object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... clang -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if clang supports -fno-rtti -fno-exceptions... yes
checking for clang option to produce PIC... -fPIC -DPIC
checking if clang PIC flag -fPIC -DPIC works... yes
checking if clang static flag -static works... yes
checking if clang supports -c -o file.o... yes
checking if clang supports -c -o file.o... (cached) yes
checking whether the clang linker (/usr/bin/x86_64-pc-linux-gnu-ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc... gcc
checking whether we are using the GNU Objective C compiler... yes
checking whether gcc accepts -g... yes
checking dependency style of gcc... gcc3
checking whether NLS is requested... yes
checking for intltool >= 0.50... 0.51.0 found
checking for intltool-update... /usr/bin/intltool-update
checking for intltool-merge... /usr/bin/intltool-merge
checking for intltool-extract... /usr/bin/intltool-extract
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/gmsgfmt
checking for perl... /usr/bin/perl
checking for perl >= 5.8.1... 5.32.0
checking for XML::Parser... ok
checking for windres... no
checking whether Objective C compiler works... yes
checking for msgfmt... (cached) /usr/bin/msgfmt
checking for gmsgfmt... (cached) /usr/bin/gmsgfmt
checking for xgettext... (cached) /usr/bin/xgettext
checking for msgmerge... (cached) /usr/bin/msgmerge
checking for ld used by GCC... /usr/bin/x86_64-pc-linux-gnu-ld -m elf_x86_64
checking if the linker (/usr/bin/x86_64-pc-linux-gnu-ld -m elf_x86_64) is GNU ld... yes
checking for shared library run path origin... done
checking for CFPreferencesCopyAppValue... no
checking for CFLocaleCopyCurrent... no
checking for GNU gettext in libc... yes
checking whether to use NLS... yes
checking where the gettext function comes from... libc
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libdrm... yes
checking for x11... yes
checking for xxf86vm... yes
checking for xcb... yes
checking for xcb-randr... yes
checking for glib-2.0 gobject-2.0... yes
checking for glib-2.0 gio-2.0 >= 2.26... yes
checking ApplicationServices/ApplicationServices.h usability... no
checking ApplicationServices/ApplicationServices.h presence... no
checking for ApplicationServices/ApplicationServices.h... no
checking whether CoreLocation/CoreLocation.h is usable... no
checking windows.h usability... no
checking windows.h presence... no
checking for windows.h... no
checking for a Python interpreter with version >= 3.2... python
checking for python... /usr/bin/python
checking for python version... 3.7
checking for python platform... linux
checking for python script directory... ${prefix}/lib/python3.7/site-packages
checking for python extension module directory... ${exec_prefix}/lib/python3.7/site-packages
checking whether to enable DRM method... yes
checking whether to enable RANDR method... yes
checking whether to enable VidMode method... yes
checking whether to enable Quartz method... missing dependencies
checking whether to enable WinGDI method... missing dependencies
checking whether to enable Geoclue2 location provider... yes
checking whether to enable CoreLocation method... missing dependencies
checking whether to enable GUI status icon... yes
checking whether to enable Ubuntu icons... no
checking for pkg-config... (cached) /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking Directory to install systemd user unit files... Package systemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `systemd.pc'
to the PKG_CONFIG_PATH environment variable
No package 'systemd' found
not enabled
checking whether to enable AppArmor profile... no
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for uint16_t... yes
checking for library containing clock_gettime... none required
checking for library containing floor... -lm
checking for setlocale... yes
checking for strchr... yes
checking for floor... yes
checking for pow... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating po/Makefile.in
config.status: creating src/Makefile
config.status: creating src/redshift-gtk/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing po/stamp-it commands

 redshift 1.12

    prefix:             /usr/local
    compiler:           clang
    cflags:             -g -O2
    ldflags:

    Adjustment methods:
    DRM:                yes
    RANDR:              yes
    VidMode:            yes
    Quartz (macOS):     no
    WinGDI (Windows):   no

    Location providers:
    Geoclue2:                   yes
    CoreLocation (macOS):       no

    GUI:                yes
    Ubuntu icons:       no
    systemd units:      no
    AppArmor profile:   no

make  all-recursive
make[1]: Entering directory '/tmp/tmp.Xa7J2qKRTj/redshift'
Making all in src
make[2]: Entering directory '/tmp/tmp.Xa7J2qKRTj/redshift/src'
Making all in redshift-gtk
make[3]: Entering directory '/tmp/tmp.Xa7J2qKRTj/redshift/src/redshift-gtk'
  GEN      redshift-gtk
make[3]: Leaving directory '/tmp/tmp.Xa7J2qKRTj/redshift/src/redshift-gtk'
make[3]: Entering directory '/tmp/tmp.Xa7J2qKRTj/redshift/src'
  CC       colorramp.o
  CC       config-ini.o
  CC       gamma-dummy.o
  CC       hooks.o
  CC       location-manual.o
  CC       options.o
  CC       pipeutils.o
  CC       redshift.o
  CC       signals.o
  CC       solar.o
  CC       systemtime.o
  CC       gamma-drm.o
  CC       gamma-randr.o
  CC       gamma-vidmode.o
  CC       location-geoclue2.o
  OBJCLD   redshift
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: colorramp.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: config-ini.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: gamma-dummy.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: hooks.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: location-manual.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: options.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: pipeutils.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: redshift.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: signals.o: relocation R_X86_64_32S against `.text' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: solar.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: systemtime.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: gamma-drm.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: gamma-randr.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: gamma-vidmode.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: location-geoclue2.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:678: redshift] Error 1
make[3]: Leaving directory '/tmp/tmp.Xa7J2qKRTj/redshift/src'
make[2]: *** [Makefile:781: all-recursive] Error 1
make[2]: Leaving directory '/tmp/tmp.Xa7J2qKRTj/redshift/src'
make[1]: *** [Makefile:778: all-recursive] Error 1
make[1]: Leaving directory '/tmp/tmp.Xa7J2qKRTj/redshift'
make: *** [Makefile:522: all] Error 2

Original downstream bug at https://bugs.gentoo.org/732438 .

Expected behavior No link errors :smiley:

Error output/logs/screenshots See section "To reproduce" above

Software versions (please complete the following information):

hartwork commented 3 years ago

@jonls any thoughts?

hartwork commented 3 years ago

@jonls any thoughts?

hartwork commented 3 years ago

PS: If anyone needs a workaround: CC=clang CFLAGS=-fPIE ./configure && make works for me.

hartwork commented 2 years ago

@jonls how would you like to continue?