File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ ifeq ($(TIMESYNC),1)
7373endif
7474
7575OS = $(shell uname -s)
76+ ARCH = $(shell uname -m)
7677
7778KRUN_BINARY_Linux = libkrun$(VARIANT ) .so.$(FULL_VERSION )
7879KRUN_SONAME_Linux = libkrun$(VARIANT ) .so.$(ABI_VERSION )
@@ -100,10 +101,18 @@ all: $(LIBRARY_RELEASE_$(OS)) libkrun.pc
100101
101102debug : $(LIBRARY_DEBUG_$(OS ) ) libkrun.pc
102103
104+ ifeq ($(SYSROOT_LINUX ) ,)
105+ # Build on Linux host
106+ CC_LINUX =$(CC )
107+ else
108+ # Cross-compile on macOS with the LLVM linker (brew install lld)
109+ CC_LINUX =clang -target $(ARCH ) -linux-gnu -fuse-ld=lld -Wl,-strip-debug --sysroot $(SYSROOT_LINUX ) -Wno-c23-extensions
110+ endif
111+
103112ifeq ($(BUILD_INIT ) ,1)
104113INIT_BINARY = init/init
105114$(INIT_BINARY ) : $(INIT_SRC )
106- $(CC ) -O2 -static -Wall $(INIT_DEFS ) -o $@ $(INIT_SRC ) $(INIT_DEFS )
115+ $(CC_LINUX ) -O2 -static -Wall $(INIT_DEFS ) -o $@ $(INIT_SRC ) $(INIT_DEFS )
107116endif
108117
109118$(LIBRARY_RELEASE_$(OS ) ) : $(INIT_BINARY )
You can’t perform that action at this time.
0 commit comments