Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building with LLVM linker (LLD) #83

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

obiwac
Copy link

@obiwac obiwac commented Apr 25, 2022

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 😄

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

LLD requires the `-m` switch to be passed during target emulation.
This was causing it to fail in `READ_ONLY_OBJECT_FROM_FILE_RULE`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant