NVIDIA / nvidia-settings

NVIDIA driver control panel
http://www.nvidia.com/object/unix.html
GNU General Public License v2.0
296 stars 77 forks source link

Fix building with LLVM linker (LLD) #83

Open obiwac opened 2 years ago

obiwac commented 2 years ago

This PR mainly fixes building with the LLVM linker (LLD), but I also took the liberty of adding a Dutch translation to the .desktop file, a .gitignore file to exclude output directories (_out), and fixing a bunch of warnings (disabled deprecation warnings so that the build doesn't fail with WARNINGS_AS_ERRORS set).

LLD requires the -m switch to be passed during target emulation; this was causing it to fail in the READ_ONLY_OBJECT_FROM_FILE_RULE function. This was fixed simply with this:

LLD_EMULATION =

ifneq ($(shell $(LD) -v | grep LLD),)
  ifeq ($(TARGET_ARCH),x86)
    LLD_EMULATION := -m elf_i386
  endif

  ifeq ($(TARGET_ARCH),x86_64)
    LLD_EMULATION := -m elf_x86_64
  endif
endif

and then by adding $(LLD_EMULATION) to the options of the linker invocation in READ_ONLY_OBJECT_FROM_FILE_RULE (I updated both utils.mk & src/libXNVCtrl/utils.mk).

Small thing to note in case it is of consequence: the output of uname -m on an x86_64 system is amd64 on FreeBSD and x86_64 on Linux. I thus added the following substitution to make things a bit more consistent and cleaner:

TARGET_ARCH         := $(shell uname -m)
TARGET_ARCH         := $(subst amd64,x86_64,$(TARGET_ARCH)) # <-- this fella
TARGET_ARCH         := $(subst i386,x86,$(TARGET_ARCH))
TARGET_ARCH         := $(subst i486,x86,$(TARGET_ARCH))
TARGET_ARCH         := $(subst i586,x86,$(TARGET_ARCH))
TARGET_ARCH         := $(subst i686,x86,$(TARGET_ARCH))

This has the side effect of changing the output path on FreeBSD from src/_out/FreeBSD_amd64 to src/_out/FreeBSD_x86_64; perhaps something to notify the nvidia-settings port maintainer about? I haven't yet done this but I will do if ever this PR is merged.

I tested this on FreeBSD 13 with Clang 11.0.1 & GCC 10.3.0 and Ubuntu 20.04 with GCC 9.3.0. All seems to be working :smile:

Sorry for the large diff - there were quite a few trailing whitespaces around the place.