diff mbox series

kvm-unit-tests: Build changes for illumos.

Message ID 20220512204459.2692060-1-cross@oxidecomputer.com (mailing list archive)
State New, archived
Headers show
Series kvm-unit-tests: Build changes for illumos. | expand

Commit Message

Dan Cross May 12, 2022, 8:45 p.m. UTC
We have begun using kvm-unit-tests to test Bhyve under
illumos.  We started by cross-compiling the tests on Linux
and transfering the binary artifacts to illumos machines,
but it proved more convenient to build them directly on
illumos.

This change modifies the build infrastructure to allow
building on illumos; I have also tested it on Linux.  The
required changes were pretty minimal: the most invasive
was switching from using the C compiler as a linker driver
to simply invoking the linker directly in two places.
This allows us to easily use gold instead of the Solaris
linker.

Signed-off-by: Dan Cross <cross@oxidecomputer.com>
---
 configure           | 5 +++--
 x86/Makefile.common | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

Comments

Sean Christopherson May 12, 2022, 10:05 p.m. UTC | #1
On Thu, May 12, 2022, Dan Cross wrote:
> We have begun using kvm-unit-tests to test Bhyve under
> illumos.  We started by cross-compiling the tests on Linux
> and transfering the binary artifacts to illumos machines,
> but it proved more convenient to build them directly on
> illumos.
> 
> This change modifies the build infrastructure to allow
> building on illumos; I have also tested it on Linux.  The
> required changes were pretty minimal: the most invasive
> was switching from using the C compiler as a linker driver
> to simply invoking the linker directly in two places.
> This allows us to easily use gold instead of the Solaris
> linker.

Can you please split this into two patches?  One for the $(CC) => $(LD) change,
and one for the getopt thing.  The switch to $(LD) in particular could be valuable
irrespective of using a non-Linux OS.

> Signed-off-by: Dan Cross <cross@oxidecomputer.com>
> ---
>  configure           | 5 +++--
>  x86/Makefile.common | 6 +++---
>  2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/configure b/configure
> index 86c3095..7193811 100755
> --- a/configure
> +++ b/configure
> @@ -15,6 +15,7 @@ objdump=objdump
>  ar=ar
>  addr2line=addr2line
>  arch=$(uname -m | sed -e 's/i.86/i386/;s/arm64/aarch64/;s/arm.*/arm/;s/ppc64.*/ppc64/')
> +os=$(uname -s)
>  host=$arch
>  cross_prefix=
>  endian=""
> @@ -317,9 +318,9 @@ EOF
>    rm -f lib-test.{o,S}
>  fi
>  
> -# require enhanced getopt
> +# require enhanced getopt everywhere except illumos
>  getopt -T > /dev/null
> -if [ $? -ne 4 ]; then
> +if [ $? -ne 4 ] && [ "$os" != "SunOS" ]; then

Presumably whatever "enhanced" features are being used are supported by illumos,
so rather than check the OS, why not improve the probing?

>      echo "Enhanced getopt is not available, add it to your PATH?"
>      exit 1
>  fi
Dan Cross May 13, 2022, 1:27 a.m. UTC | #2
[Sean, sorry for the dup; I forgot to switch to plaintext mode]

On Thu, May 12, 2022 at 6:05 PM Sean Christopherson <seanjc@google.com> wrote:
> On Thu, May 12, 2022, Dan Cross wrote:
> > We have begun using kvm-unit-tests to test Bhyve under
> > illumos.  We started by cross-compiling the tests on Linux
> > and transfering the binary artifacts to illumos machines,
> > but it proved more convenient to build them directly on
> > illumos.
> >
> > This change modifies the build infrastructure to allow
> > building on illumos; I have also tested it on Linux.  The
> > required changes were pretty minimal: the most invasive
> > was switching from using the C compiler as a linker driver
> > to simply invoking the linker directly in two places.
> > This allows us to easily use gold instead of the Solaris
> > linker.
>
> Can you please split this into two patches?  One for the $(CC) => $(LD) change,
> and one for the getopt thing.  The switch to $(LD) in particular could be valuable
> irrespective of using a non-Linux OS.

Done.

> [snip]
>
> > +# require enhanced getopt everywhere except illumos
> >  getopt -T > /dev/null
> > -if [ $? -ne 4 ]; then
> > +if [ $? -ne 4 ] && [ "$os" != "SunOS" ]; then
>
> Presumably whatever "enhanced" features are being used are supported by illumos,
> so rather than check the OS, why not improve the probing?

Actually, it looks like I've got some egg on my face here. It appears
that `getopt`
is not used in `configure` beyond this check; presumably this exists
to avoid surprises
when running `run_tests.sh`, which does use extended getopt (for long
options) and
repeats this same test. I had not noticed since `configure` ran
successfully, and we are
not presently using `run_tests.sh` on illumos as we use a rather
different VMM than
qemu. That patch should probably be dropped (or changed to remove the
getopt check
in `configure` entirely, if folks are fine deferring needing to have
it to the invocation of
`run_tests.sh`...). Or I just convince folks to provide a GNU getopt
package on illumos.
Let me know what is preferred.

        - Dan C.
diff mbox series

Patch

diff --git a/configure b/configure
index 86c3095..7193811 100755
--- a/configure
+++ b/configure
@@ -15,6 +15,7 @@  objdump=objdump
 ar=ar
 addr2line=addr2line
 arch=$(uname -m | sed -e 's/i.86/i386/;s/arm64/aarch64/;s/arm.*/arm/;s/ppc64.*/ppc64/')
+os=$(uname -s)
 host=$arch
 cross_prefix=
 endian=""
@@ -317,9 +318,9 @@  EOF
   rm -f lib-test.{o,S}
 fi
 
-# require enhanced getopt
+# require enhanced getopt everywhere except illumos
 getopt -T > /dev/null
-if [ $? -ne 4 ]; then
+if [ $? -ne 4 ] && [ "$os" != "SunOS" ]; then
     echo "Enhanced getopt is not available, add it to your PATH?"
     exit 1
 fi
diff --git a/x86/Makefile.common b/x86/Makefile.common
index b903988..0a0f7b9 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -62,7 +62,7 @@  else
 .PRECIOUS: %.elf %.o
 
 %.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
-	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
+	$(LD) -T $(SRCDIR)/x86/flat.lds -nostdlib -o $@ \
 		$(filter %.o, $^) $(FLATLIBS)
 	@chmod a-x $@
 
@@ -98,8 +98,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)