public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Cross <cross@oxidecomputer.com>
To: kvm@vger.kernel.org
Cc: Andrew Jones <drjones@redhat.com>, Thomas Huth <thuth@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Dan Cross <cross@oxidecomputer.com>
Subject: [PATCH v4 2/2] kvm-unit-tests: invoke $LD explicitly
Date: Wed,  1 Jun 2022 21:57:49 +0000	[thread overview]
Message-ID: <20220601215749.30223-3-cross@oxidecomputer.com> (raw)
In-Reply-To: <20220601215749.30223-1-cross@oxidecomputer.com>

Change x86/Makefile.common to invoke the linker directly instead
of using the C compiler as a linker driver.  Plumb LDFLAGS through
to the linker.

This supports building on illumos, allowing the user to use
gold instead of the Solaris linker.  Tested on Linux and illumos.

Signed-off-by: Dan Cross <cross@oxidecomputer.com>
---
 x86/Makefile.common | 9 +++++----
 x86/Makefile.i386   | 1 +
 x86/Makefile.x86_64 | 2 ++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/x86/Makefile.common b/x86/Makefile.common
index b903988..a600c72 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -30,7 +30,7 @@ endif
 
 OBJDIRS += lib/x86
 
-$(libcflat): LDFLAGS += -nostdlib
+$(libcflat): LDFLAGS += -nostdlib $(arch_LDFLAGS)
 $(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
 
 COMMON_CFLAGS += -m$(bits)
@@ -61,8 +61,9 @@ else
 # We want to keep intermediate file: %.elf and %.o
 .PRECIOUS: %.elf %.o
 
+%.elf: LDFLAGS = -nostdlib $(arch_LDFLAGS)
 %.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
-	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
+	$(LD) $(LDFLAGS) -T $(SRCDIR)/x86/flat.lds -o $@ \
 		$(filter %.o, $^) $(FLATLIBS)
 	@chmod a-x $@
 
@@ -98,8 +99,8 @@ test_cases: $(tests-common) $(tests)
 $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
 
 $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
-	$(CC) -m32 -nostdlib -o $@ -Wl,-m,elf_i386 \
-	      -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^
+	$(LD) -m elf_i386 -nostdlib -o $@ \
+	      -T $(SRCDIR)/$(TEST_DIR)/realmode.lds $^
 
 $(TEST_DIR)/realmode.o: bits = $(if $(call cc-option,-m16,""),16,32)
 
diff --git a/x86/Makefile.i386 b/x86/Makefile.i386
index 7d19d55..0a845e6 100644
--- a/x86/Makefile.i386
+++ b/x86/Makefile.i386
@@ -4,6 +4,7 @@ ldarch = elf32-i386
 exe = flat
 bin = elf
 COMMON_CFLAGS += -mno-sse -mno-sse2
+arch_LDFLAGS = -m elf_i386
 
 cflatobjs += lib/x86/setjmp32.o lib/ldiv32.o
 
diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64
index f18c1e2..e19284a 100644
--- a/x86/Makefile.x86_64
+++ b/x86/Makefile.x86_64
@@ -6,9 +6,11 @@ exe = efi
 bin = so
 FORMAT = efi-app-x86_64
 cstart.o = $(TEST_DIR)/efi/efistart64.o
+arch_LDFLAGS = ''
 else
 exe = flat
 bin = elf
+arch_LDFLAGS = -m elf_x86_64
 endif
 
 fcf_protection_full := $(call cc-option, -fcf-protection=full,)
-- 
2.36.1


  parent reply	other threads:[~2022-06-01 21:58 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 20:45 [PATCH] kvm-unit-tests: Build changes for illumos Dan Cross
2022-05-12 22:05 ` Sean Christopherson
2022-05-13  1:07   ` [PATCH 0/2] kvm-unit-tests: Build changes to support illumos Dan Cross
2022-05-13  1:07     ` [PATCH 1/2] kvm-unit-tests: invoke $LD explicitly in Dan Cross
2022-05-13  1:07     ` [PATCH 2/2] kvm-unit-tests: configure changes for illumos Dan Cross
2022-05-13 14:34       ` Sean Christopherson
2022-05-19  9:53         ` Thomas Huth
2022-05-24 21:20           ` Dan Cross
2022-05-25  7:41             ` Thomas Huth
2022-05-24 21:22         ` Dan Cross
2022-05-25  7:44           ` Thomas Huth
2022-05-26  7:11             ` Andrew Jones
2022-05-26 17:39               ` [PATCH 0/2] kvm-unit-tests: Build changes to support illumos Dan Cross
2022-05-26 17:39                 ` [PATCH 1/2] kvm-unit-tests: invoke $LD explicitly in Dan Cross
2022-05-26 21:17                   ` Sean Christopherson
2022-06-01  7:03                   ` Thomas Huth
2022-06-01 17:09                     ` Dan Cross
2022-06-01 17:43                       ` Andrew Jones
2022-06-01 21:51                         ` Dan Cross
2022-06-01 21:57                           ` [PATCH v4 0/2] kvm-unit-tests: Build changes to support illumos Dan Cross
2022-06-01 21:57                             ` [PATCH v4 1/2] kvm-unit-tests: configure changes for illumos Dan Cross
2022-06-01 21:57                             ` Dan Cross [this message]
2022-06-02 10:53                             ` [PATCH v4 0/2] kvm-unit-tests: Build changes to support illumos Thomas Huth
2022-06-02 11:32                               ` Dan Cross
2022-05-26 17:39                 ` [PATCH 2/2] kvm-unit-tests: configure changes for illumos Dan Cross
2022-05-26 21:23                   ` Sean Christopherson
2022-05-26 22:17                     ` Dan Cross
2022-05-27 14:41                       ` Sean Christopherson
2022-05-31 17:02                         ` Dan Cross
2022-05-26 17:40               ` Dan Cross
     [not found]   ` <CAA9fzEGdi0k8bkyXQwvt6gFd-gwHNNFF7A89U4DhtGHjKqe4AQ@mail.gmail.com>
2022-05-13  1:27     ` Fwd: [PATCH] kvm-unit-tests: Build " Dan Cross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220601215749.30223-3-cross@oxidecomputer.com \
    --to=cross@oxidecomputer.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox