Skip to content

[LLDB][test] Update Makefile.rules to support Windows host+Linux target #99266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 43 additions & 25 deletions lldb/packages/Python/lldbsuite/test/make/Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,26 @@ $(error "C compiler is not specified. Please run tests through lldb-dotest or li
endif

#----------------------------------------------------------------------
# Handle SDKROOT on Darwin
# Handle SDKROOT for the cross platform builds.
#----------------------------------------------------------------------

ifeq "$(OS)" "Darwin"
ifeq "$(SDKROOT)" ""
# We haven't otherwise set the SDKROOT, so set it now to macosx
SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path)
endif
SYSROOT_FLAGS := -isysroot "$(SDKROOT)"
GCC_TOOLCHAIN_FLAGS :=
else
ifneq "$(SDKROOT)" ""
SYSROOT_FLAGS := --sysroot "$(SDKROOT)"
GCC_TOOLCHAIN_FLAGS := --gcc-toolchain="$(SDKROOT)/usr"
else
# Do not set up these options if SDKROOT was not specified.
# This is a regular build in that case (or Android).
SYSROOT_FLAGS :=
GCC_TOOLCHAIN_FLAGS :=
endif
endif

#----------------------------------------------------------------------
Expand Down Expand Up @@ -210,20 +222,15 @@ endif
DEBUG_INFO_FLAG ?= -g

CFLAGS ?= $(DEBUG_INFO_FLAG) -O0

ifeq "$(OS)" "Darwin"
ifneq "$(SDKROOT)" ""
CFLAGS += -isysroot "$(SDKROOT)"
endif
endif
CFLAGS += $(SYSROOT_FLAGS)

ifeq "$(OS)" "Darwin"
CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES)
else
CFLAGS += $(ARCHFLAG)$(ARCH)
endif
CFLAGS += -I$(LLDB_BASE_DIR)include -I$(LLDB_OBJ_ROOT)/include

CFLAGS += -I$(LLDB_BASE_DIR)/include -I$(LLDB_OBJ_ROOT)/include
CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR)

ifndef NO_TEST_COMMON_H
Expand All @@ -234,9 +241,9 @@ CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS)

# Use this one if you want to build one part of the result without debug information:
ifeq "$(OS)" "Darwin"
CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) -isysroot "$(SDKROOT)"
CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)
else
CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)
endif

ifeq "$(MAKE_DWO)" "YES"
Expand Down Expand Up @@ -267,7 +274,9 @@ endif
CFLAGS += $(CFLAGS_EXTRAS)
CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS)
LD = $(CC)
LDFLAGS ?= $(CFLAGS)
# Copy common options to the linker flags (dwarf, arch. & etc).
# Note: we get some 'garbage' options for linker here (such as -I, --isystem & etc).
LDFLAGS += $(CFLAGS)
LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)
ifeq (,$(filter $(OS), Windows_NT Android Darwin))
ifneq (,$(filter YES,$(ENABLE_THREADS)))
Expand Down Expand Up @@ -378,11 +387,26 @@ ifeq (1, $(USE_SYSTEM_STDLIB))
endif
endif

ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB)))
# If no explicit C++ library request was made, but we have paths to a custom libcxx, use
# them. Otherwise, use the system library by default.
ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)
ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)
endif
LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
else
USE_SYSTEM_STDLIB := 1
endif
endif

ifeq (1,$(USE_LIBSTDCPP))
# Clang requires an extra flag: -stdlib=libstdc++
ifneq (,$(findstring clang,$(CC)))
CXXFLAGS += -stdlib=libstdc++
LDFLAGS += -stdlib=libstdc++
# Force clang looking for the gcc's headers at specific rootfs folder.
CXXFLAGS += -stdlib=libstdc++ $(GCC_TOOLCHAIN_FLAGS)
LDFLAGS += -stdlib=libstdc++ $(GCC_TOOLCHAIN_FLAGS)
endif
endif

Expand Down Expand Up @@ -416,21 +440,15 @@ ifeq (1, $(USE_SYSTEM_STDLIB))
endif
CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(SDKROOT)/usr/include/c++/v1
LDFLAGS += -L$(SDKROOT)/usr/lib -Wl,-rpath,$(SDKROOT)/usr/lib -lc++
else
ifneq (,$(findstring clang,$(CC)))
# Force clang looking for the gcc's headers at specific rootfs folder.
CXXFLAGS += $(GCC_TOOLCHAIN_FLAGS)
LDFLAGS += $(GCC_TOOLCHAIN_FLAGS)
endif
endif
endif

# If no explicit request was made, but we have paths to a custom libcxx, use
# them.
ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), $(USE_SYSTEM_STDLIB)),)
ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)
ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)
endif
LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
endif
endif

#----------------------------------------------------------------------
# Additional system libraries
#----------------------------------------------------------------------
Expand Down
Loading