[Skiboot] [PATCH 4/7] test: Simplify build process for hello and sreset tests

Joel Stanley joel at jms.id.au
Tue May 8 20:23:00 AEST 2018


Link with ld instead of gcc so we can build with clang as cc.

Remove the linker script and unnecessary flags. The application links
just fine without them.

Add cflags required by clang in order to build for the correct target.

Remove the dependency file generation. The assembly files don't include
any headers, so they weren't doing anything.

Simplify clean rule, as the $(RM) alias does -f for us, and we no longer
have .d files.

Build tested on ppc64le and amd64. Booted in Qemu on both using:

  qemu-system-ppc64 -M powernv -nodefaults -nographic -serial stdio \
	  -kernel test/hello_world/hello_kernel/hello_kernel

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 test/hello_world/Makefile.check               | 21 ++++++++------
 test/hello_world/hello_kernel/hello_kernel.ld | 29 -------------------
 test/sreset_world/Makefile.check              | 21 ++++++++------
 .../sreset_kernel/sreset_kernel.ld            | 29 -------------------
 4 files changed, 24 insertions(+), 76 deletions(-)
 delete mode 100644 test/hello_world/hello_kernel/hello_kernel.ld
 delete mode 100644 test/sreset_world/sreset_kernel/sreset_kernel.ld

diff --git a/test/hello_world/Makefile.check b/test/hello_world/Makefile.check
index e791ea76b72b..0390cf662285 100644
--- a/test/hello_world/Makefile.check
+++ b/test/hello_world/Makefile.check
@@ -16,6 +16,13 @@ hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-p9-mambo)
 boot-tests: hello_world-tests
 check: hello_world-tests
 
+cc-name := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
+
+ifeq ($(cc-name),clang)
+hello_kernel_CFLAGS = --target=powerpc64-linux-gnu
+endif
+hello_kernel_CFLAGS += -mbig-endian -m64
+
 $(HELLO_WORLD_TEST:%=%-check-smt-mambo): %-check-smt-mambo: % skiboot.lid
 	$(call Q , BOOT TEST , THREADS=2 ./test/hello_world/run_mambo_hello_world.sh , $@)
 
@@ -46,15 +53,11 @@ $(HELLO_WORLD_STB_TEST:%=%-check-stb-p9-mambo): %-check-stb-p9-mambo: % skiboot.
 $(HELLO_WORLD_TEST:%=%-check-qemu): %-check-qemu: % skiboot.lid
 	$(call Q , BOOT TEST , ./test/hello_world/run_qemu_hello_world.sh, $@)
 
-test/hello_world/hello_kernel/hello_kernel.o: test/hello_world/hello_kernel/hello_kernel.S test/hello_world/hello_kernel/hello_kernel.ld
-	$(call Q,CC, $(CC) -m64 -c -MMD -o $@ $< ,$@)
-
-hello_kernel_LDFLAGS=-m64 -Wl,--build-id=none -T test/hello_world/hello_kernel/hello_kernel.ld -ffreestanding -nostdlib -Ttext=0x0 -N
-
--include $(wildcard test/hello_world/hello_kernel/*.d)
+test/hello_world/hello_kernel/hello_kernel.o: test/hello_world/hello_kernel/hello_kernel.S
+	$(call Q,CC, $(CC) $(hello_kernel_CFLAGS) -c -o $@ $< ,$@)
 
 test/hello_world/hello_kernel/hello_kernel: test/hello_world/hello_kernel/hello_kernel.o
-	$(call Q,LD, $(CC) $(hello_kernel_LDFLAGS) -o $@ $^ , $@)
+	$(call Q,LD, $(LD) -EB -m elf64ppc -N -o $@ $^ , $@)
 
 test/hello_world/hello_kernel/hello_kernel.stb: test/hello_world/hello_kernel/hello_kernel libstb/create-container
 	$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/,$@)
@@ -62,5 +65,5 @@ test/hello_world/hello_kernel/hello_kernel.stb: test/hello_world/hello_kernel/he
 clean: hello_world-test-clean
 
 hello_world-test-clean:
-	$(RM) -f test/hello_world/hello_kernel/hello_kernel
-	$(RM) -f test/hello_world/hello_kernel/hello_kernel.[od]
+	$(RM) test/hello_world/hello_kernel/hello_kernel
+	$(RM) test/hello_world/hello_kernel/hello_kernel.o
diff --git a/test/hello_world/hello_kernel/hello_kernel.ld b/test/hello_world/hello_kernel/hello_kernel.ld
deleted file mode 100644
index d9bbc92857b2..000000000000
--- a/test/hello_world/hello_kernel/hello_kernel.ld
+++ /dev/null
@@ -1,29 +0,0 @@
-ENTRY(_start)
-SECTIONS
-{
-	.text :
-	{
-		_start = .;
-		*(.text)
-	}
-
-	. = ALIGN(4096);
-	.data :
-	{
-		*(.rodata*)
-		*(.data*)
-		*(.sdata*)
-		*(.got2)
-	}
-
-	. = ALIGN(4096);
-	.bss :
-	{
-		_edata  =  .;
-		__bss_start = .;
-		*(.sbss)
-		*(.bss)
-		*(COMMON)
-		_end = . ;
-	}
-}
diff --git a/test/sreset_world/Makefile.check b/test/sreset_world/Makefile.check
index 1bd7b4071f5e..ec9fd2747274 100644
--- a/test/sreset_world/Makefile.check
+++ b/test/sreset_world/Makefile.check
@@ -12,6 +12,13 @@ sreset_world-tests: $(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo)
 boot-tests: sreset_world-tests
 check: sreset_world-tests
 
+cc-name := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
+
+ifeq ($(cc-name),clang)
+sreset_kernel_CFLAGS = --target=powerpc64-linux-gnu
+endif
+sreset_kernel_CFLAGS += -mbig-endian -m64
+
 $(SRESET_WORLD_TEST:%=%-check-smt-mambo): %-check-smt-mambo: % skiboot.lid
 	$(call Q , BOOT TEST , THREADS=2 ./test/sreset_world/run_mambo_sreset.sh , $@)
 
@@ -24,15 +31,11 @@ $(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-mambo): %-check-stb-smt-mambo: % skibo
 $(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo): %-check-stb-smt-p9-mambo: % skiboot.lid.stb
 	$(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 THREADS=2 ./test/sreset_world/run_mambo_p9_sreset.sh , $@)
 
-test/sreset_world/sreset_kernel/sreset_kernel.o: test/sreset_world/sreset_kernel/sreset_kernel.S test/sreset_world/sreset_kernel/sreset_kernel.ld
-	$(call Q,CC, $(CC) -mbig-endian -m64 -c -MMD -o $@ $< ,$@)
-
-sreset_kernel_LDFLAGS=-m64 -Wl,--build-id=none -T test/sreset_world/sreset_kernel/sreset_kernel.ld -ffreestanding -nostdlib -Ttext=0x0 -mbig-endian -N
-
--include $(wildcard test/sreset_world/sreset_kernel/*.d)
+test/sreset_world/sreset_kernel/sreset_kernel.o: test/sreset_world/sreset_kernel/sreset_kernel.S
+	$(call Q,CC, $(CC) $(sreset_kernel_CFLAGS) -c -o $@ $< ,$@)
 
 test/sreset_world/sreset_kernel/sreset_kernel: test/sreset_world/sreset_kernel/sreset_kernel.o
-	$(call Q,LD, $(CC) $(sreset_kernel_LDFLAGS) -o $@ $^ , $@)
+	$(call Q,LD, $(LD) -EB -m elf64ppc -N -o $@ $^ , $@)
 
 test/sreset_world/sreset_kernel/sreset_kernel.stb: test/sreset_world/sreset_kernel/sreset_kernel libstb/create-container
 	$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/,$@)
@@ -41,5 +44,5 @@ test/sreset_world/sreset_kernel/sreset_kernel.stb: test/sreset_world/sreset_kern
 clean: sreset_world-test-clean
 
 sreset_world-test-clean:
-	$(RM) -f test/sreset_world/sreset_kernel/sreset_kernel
-	$(RM) -f test/sreset_world/sreset_kernel/sreset_kernel.[od]
+	$(RM) test/sreset_world/sreset_kernel/sreset_kernel
+	$(RM) test/sreset_world/sreset_kernel/sreset_kernel.o
diff --git a/test/sreset_world/sreset_kernel/sreset_kernel.ld b/test/sreset_world/sreset_kernel/sreset_kernel.ld
deleted file mode 100644
index d9bbc92857b2..000000000000
--- a/test/sreset_world/sreset_kernel/sreset_kernel.ld
+++ /dev/null
@@ -1,29 +0,0 @@
-ENTRY(_start)
-SECTIONS
-{
-	.text :
-	{
-		_start = .;
-		*(.text)
-	}
-
-	. = ALIGN(4096);
-	.data :
-	{
-		*(.rodata*)
-		*(.data*)
-		*(.sdata*)
-		*(.got2)
-	}
-
-	. = ALIGN(4096);
-	.bss :
-	{
-		_edata  =  .;
-		__bss_start = .;
-		*(.sbss)
-		*(.bss)
-		*(COMMON)
-		_end = . ;
-	}
-}
-- 
2.17.0



More information about the Skiboot mailing list