aboutsummaryrefslogtreecommitdiffstats
path: root/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-x86-fix-efi-binary-generation-issue-in-cross-compila.patch
blob: fd6fc6babccf222a6d37782d81400d724ce01543 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From cfde3b1018c3151b6cc1fbe3e9e163d0aaf16954 Mon Sep 17 00:00:00 2001
From: Naveen Saini <naveen.kumar.saini@intel.com>
Date: Tue, 11 May 2021 13:46:39 +0800
Subject: [PATCH] x86: fix efi binary generation issue in cross compilation env

Set root directory for headers.

Upstream-Status: Inappropriate [Cross-compilation specific]

Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
---
 arch/x86/zefi/zefi.py                | 6 +++++-
 boards/x86/ehl_crb/CMakeLists.txt    | 1 +
 boards/x86/qemu_x86/CMakeLists.txt   | 1 +
 boards/x86/up_squared/CMakeLists.txt | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/zefi/zefi.py b/arch/x86/zefi/zefi.py
index d3514391a8..b9eccbfa10 100755
--- a/arch/x86/zefi/zefi.py
+++ b/arch/x86/zefi/zefi.py
@@ -106,7 +106,10 @@ def build_elf(elf_file):
     #  + We need pic to enforce that the linker adds no relocations
     #  + UEFI can take interrupts on our stack, so no red zone
     #  + UEFI API assumes 16-bit wchar_t
-    cmd = [args.compiler, "-shared", "-Wall", "-Werror", "-I.",
+
+    #  Pass --sysroot path for cross compilation
+    sysrootarg = "--sysroot=" + args.sysroot
+    cmd = [args.compiler, "-shared", "-Wall", "-Werror", "-I.", sysrootarg,
         "-fno-stack-protector", "-fpic", "-mno-red-zone", "-fshort-wchar",
         "-Wl,-nostdlib", "-T", ldscript, "-o", "zefi.elf", cfile]
     verbose(" ".join(cmd))
@@ -145,6 +148,7 @@ def parse_args():
     parser.add_argument("-o", "--objcopy", required=True, help="objcopy to be used")
     parser.add_argument("-f", "--elf-file", required=True, help="Input file")
     parser.add_argument("-v", "--verbose", action="store_true", help="Verbose output")
+    parser.add_argument("-s", "--sysroot", required=True, help="Cross compilation --sysroot=path")
 
     return parser.parse_args()
 
diff --git a/boards/x86/ehl_crb/CMakeLists.txt b/boards/x86/ehl_crb/CMakeLists.txt
index 0d572eff30..6a228107dc 100644
--- a/boards/x86/ehl_crb/CMakeLists.txt
+++ b/boards/x86/ehl_crb/CMakeLists.txt
@@ -5,6 +5,7 @@ set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
   -c ${CMAKE_C_COMPILER}
   -o ${CMAKE_OBJCOPY}
   -f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf
+  -s ${SYSROOT_DIR}
   $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
   WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
 )
diff --git a/boards/x86/qemu_x86/CMakeLists.txt b/boards/x86/qemu_x86/CMakeLists.txt
index 1131a5c7ce..489f17192b 100644
--- a/boards/x86/qemu_x86/CMakeLists.txt
+++ b/boards/x86/qemu_x86/CMakeLists.txt
@@ -4,6 +4,7 @@ set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
   -c ${CMAKE_C_COMPILER}
   -o ${CMAKE_OBJCOPY}
   -f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf
+  -s ${SYSROOT_DIR}
   $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
   WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
 )
diff --git a/boards/x86/up_squared/CMakeLists.txt b/boards/x86/up_squared/CMakeLists.txt
index 0eaa9753fc..2e8ce7cfbc 100644
--- a/boards/x86/up_squared/CMakeLists.txt
+++ b/boards/x86/up_squared/CMakeLists.txt
@@ -5,6 +5,7 @@ set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
   -c ${CMAKE_C_COMPILER}
   -o ${CMAKE_OBJCOPY}
   -f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf
+  -s ${SYSROOT_DIR}
   $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
   WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
 )
-- 
2.17.1