mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
This patch enables ENABLE_SHARED=1 to build DLL based LLVM toolchain on MingW & Cygwin.
Patch by Takumi Nakamura! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111268 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c5ed0134a7
commit
59a430f68f
@ -410,6 +410,26 @@ LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
|
|||||||
LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
|
LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
|
||||||
LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
|
LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Locations of shared libraries
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
SharedPrefix := lib
|
||||||
|
SharedLibDir := $(LibDir)
|
||||||
|
LLVMSharedLibDir := $(LLVMLibDir)
|
||||||
|
|
||||||
|
# Win32.DLL prefers to be located on the "PATH" of binaries.
|
||||||
|
ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
|
||||||
|
SharedLibDir := $(ToolDir)
|
||||||
|
LLVMSharedLibDir := $(LLVMToolDir)
|
||||||
|
|
||||||
|
ifeq ($(HOST_OS),Cygwin)
|
||||||
|
SharedPrefix := cyg
|
||||||
|
else
|
||||||
|
SharedPrefix :=
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# LLVM Capable Compiler
|
# LLVM Capable Compiler
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -483,12 +503,7 @@ ifeq ($(HOST_OS),Darwin)
|
|||||||
SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
|
SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
ifeq ($(HOST_OS),Cygwin)
|
|
||||||
SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
|
|
||||||
-Wl,--enable-auto-import -Wl,--enable-auto-image-base
|
|
||||||
else
|
|
||||||
SharedLinkOptions=-shared
|
SharedLinkOptions=-shared
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET_OS),Darwin)
|
ifeq ($(TARGET_OS),Darwin)
|
||||||
@ -498,11 +513,13 @@ ifeq ($(TARGET_OS),Darwin)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef SHARED_LIBRARY
|
ifdef SHARED_LIBRARY
|
||||||
|
ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
|
||||||
ifneq ($(HOST_OS),Darwin)
|
ifneq ($(HOST_OS),Darwin)
|
||||||
LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
|
LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
|
||||||
else
|
else
|
||||||
ifneq ($(DARWIN_MAJVERS),4)
|
ifneq ($(DARWIN_MAJVERS),4)
|
||||||
LD.Flags += $(RPATH) -Wl,$(LibDir)
|
LD.Flags += $(RPATH) -Wl,$(SharedLibDir)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -873,6 +890,13 @@ LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
|
|||||||
LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
|
LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Win32.DLL may refer to other components.
|
||||||
|
ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
|
||||||
|
ifdef LOADABLE_MODULE
|
||||||
|
LINK_COMPONENTS := all
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifndef IS_CLEANING_TARGET
|
ifndef IS_CLEANING_TARGET
|
||||||
ifdef LINK_COMPONENTS
|
ifdef LINK_COMPONENTS
|
||||||
|
|
||||||
@ -885,8 +909,13 @@ $(LLVM_CONFIG):
|
|||||||
$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
|
$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
|
||||||
|
|
||||||
ifeq ($(ENABLE_SHARED), 1)
|
ifeq ($(ENABLE_SHARED), 1)
|
||||||
|
# We can take the "auto-import" feature to get rid of using dllimport.
|
||||||
|
ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
|
||||||
|
LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
|
||||||
|
-L $(SharedLibDir)
|
||||||
|
endif
|
||||||
LLVMLibsOptions += -lLLVM-$(LLVMVersion)
|
LLVMLibsOptions += -lLLVM-$(LLVMVersion)
|
||||||
LLVMLibsPaths += $(LibDir)/libLLVM-$(LLVMVersion)$(SHLIBEXT)
|
LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
|
||||||
else
|
else
|
||||||
LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
|
LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
|
||||||
LLVMLibsPaths += $(LLVM_CONFIG) \
|
LLVMLibsPaths += $(LLVM_CONFIG) \
|
||||||
@ -931,6 +960,21 @@ ifeq ($(HOST_OS),Darwin)
|
|||||||
LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
|
LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# GNU ld Win32 accepts .DEF files that contain "DATA" entries.
|
||||||
|
ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
|
||||||
|
NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
|
||||||
|
|
||||||
|
# LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
|
||||||
|
SharedLinkOptions += $(NativeExportsFile)
|
||||||
|
|
||||||
|
$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
|
||||||
|
$(Echo) Generating $(notdir $@)
|
||||||
|
$(Verb) $(ECHO) "EXPORTS" > $@
|
||||||
|
$(Verb) $(CAT) $< >> $@
|
||||||
|
clean-local::
|
||||||
|
-$(Verb) $(RM) -f $(NativeExportsFile)
|
||||||
|
else
|
||||||
|
|
||||||
# gold, bfd ld, etc.
|
# gold, bfd ld, etc.
|
||||||
ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
|
ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
|
||||||
LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
|
LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
|
||||||
@ -938,6 +982,8 @@ endif
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Library Build Rules: Four ways to build a library
|
# Library Build Rules: Four ways to build a library
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -1010,10 +1056,10 @@ ifdef LIBRARYNAME
|
|||||||
LIBRARYNAME := $(strip $(LIBRARYNAME))
|
LIBRARYNAME := $(strip $(LIBRARYNAME))
|
||||||
ifdef LOADABLE_MODULE
|
ifdef LOADABLE_MODULE
|
||||||
LibName.A := $(LibDir)/$(LIBRARYNAME).a
|
LibName.A := $(LibDir)/$(LIBRARYNAME).a
|
||||||
LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
|
LibName.SO := $(SharedLibDir)/$(LIBRARYNAME)$(SHLIBEXT)
|
||||||
else
|
else
|
||||||
LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
|
LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
|
||||||
LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
|
LibName.SO := $(SharedLibDir)/$(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
|
||||||
endif
|
endif
|
||||||
LibName.O := $(LibDir)/$(LIBRARYNAME).o
|
LibName.O := $(LibDir)/$(LIBRARYNAME).o
|
||||||
LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
|
LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
|
||||||
@ -1038,13 +1084,13 @@ SharedLibKindMessage := "Loadable Module"
|
|||||||
else
|
else
|
||||||
SharedLibKindMessage := "Shared Library"
|
SharedLibKindMessage := "Shared Library"
|
||||||
endif
|
endif
|
||||||
$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
|
$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
|
||||||
$(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
|
$(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
|
||||||
$(notdir $@)
|
$(notdir $@)
|
||||||
$(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
|
$(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
|
||||||
$(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
|
$(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
|
||||||
else
|
else
|
||||||
$(LibName.SO): $(ObjectsO) $(LibDir)/.dir
|
$(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
|
||||||
$(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
|
$(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
|
||||||
$(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
|
$(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
|
||||||
endif
|
endif
|
||||||
@ -1061,21 +1107,23 @@ uninstall-local::
|
|||||||
$(Echo) Uninstall circumvented with NO_INSTALL
|
$(Echo) Uninstall circumvented with NO_INSTALL
|
||||||
else
|
else
|
||||||
|
|
||||||
ifdef LOADABLE_MODULE
|
# Win32.DLL prefers to be located on the "PATH" of binaries.
|
||||||
DestSharedLib = $(DESTDIR)$(PROJ_libdir)/$(LIBRARYNAME)$(SHLIBEXT)
|
ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
|
||||||
|
DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
|
||||||
else
|
else
|
||||||
DestSharedLib = $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
|
DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
|
||||||
endif
|
endif
|
||||||
|
DestSharedLib := $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
|
||||||
|
|
||||||
install-local:: $(DestSharedLib)
|
install-local:: $(DestSharedLib)
|
||||||
|
|
||||||
$(DestSharedLib): $(LibName.SO) $(DESTDIR)$(PROJ_libdir)
|
$(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
|
||||||
$(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
|
$(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
|
||||||
$(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
|
$(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
|
||||||
|
|
||||||
uninstall-local::
|
uninstall-local::
|
||||||
$(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
|
$(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
|
||||||
-$(Verb) $(RM) -f $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).*
|
-$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -15,6 +15,17 @@ NO_BUILD_ARCHIVE = 1
|
|||||||
LINK_LIBS_IN_SHARED = 1
|
LINK_LIBS_IN_SHARED = 1
|
||||||
SHARED_LIBRARY = 1
|
SHARED_LIBRARY = 1
|
||||||
|
|
||||||
|
include $(LEVEL)/Makefile.config
|
||||||
|
|
||||||
|
ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
|
||||||
|
EXPORTED_SYMBOL_FILE = $(ObjDir)/$(LIBRARYNAME).exports
|
||||||
|
|
||||||
|
# It is needed to force static-stdc++.a linked.
|
||||||
|
# FIXME: It should be omitted when configure detects system's stdc++.dll.
|
||||||
|
SHLIB_FRAG_NAMES += stdc++.a.o
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
# Include all archives in libLLVM.(so|dylib) except the ones that have
|
# Include all archives in libLLVM.(so|dylib) except the ones that have
|
||||||
@ -57,3 +68,44 @@ ifeq ($(HOST_OS), Linux)
|
|||||||
# Don't allow unresolved symbols.
|
# Don't allow unresolved symbols.
|
||||||
LLVMLibsOptions += -Wl,--no-undefined
|
LLVMLibsOptions += -Wl,--no-undefined
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
|
||||||
|
|
||||||
|
SHLIB_STUBS := $(addprefix $(ObjDir)/, $(SHLIB_FRAG_NAMES))
|
||||||
|
SHLIB_FRAGS := $(patsubst %.a.o, $(ObjDir)/%.syms.txt, $(LIBRARYNAME).a.o $(SHLIB_FRAG_NAMES))
|
||||||
|
LLVMLibsOptions := $(SHLIB_STUBS) $(LLVMLibsOptions)
|
||||||
|
|
||||||
|
$(LibName.SO): $(SHLIB_STUBS)
|
||||||
|
|
||||||
|
%.syms.txt: %.a.o
|
||||||
|
$(Echo) Collecting global symbols of $(notdir $*)
|
||||||
|
$(Verb) $(NM_PATH) -g $< > $@
|
||||||
|
|
||||||
|
$(ObjDir)/$(LIBRARYNAME).exports: $(SHLIB_FRAGS) $(ObjDir)/.dir
|
||||||
|
$(Echo) Generating exports for $(LIBRARYNAME)
|
||||||
|
$(Verb) ($(SED) -n \
|
||||||
|
-e "s/^.* T _\([^.][^.]*\)$$/\1/p" \
|
||||||
|
-e "s/^.* [BDR] _\([^.][^.]*\)$$/\1 DATA/p" \
|
||||||
|
$(SHLIB_FRAGS) \
|
||||||
|
| sort -u) > $@
|
||||||
|
|
||||||
|
$(ObjDir)/$(LIBRARYNAME).a.o: $(LLVMLibsPaths) $(ObjDir)/.dir
|
||||||
|
$(Echo) Linking all LLVMLibs together for $(LIBRARYNAME)
|
||||||
|
$(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \
|
||||||
|
-Wl,--whole-archive $(LLVMLibsPaths) \
|
||||||
|
-Wl,--no-whole-archive
|
||||||
|
|
||||||
|
$(ObjDir)/stdc++.a.o: $(ObjDir)/.dir
|
||||||
|
$(Echo) Linking all libs together for static libstdc++.a
|
||||||
|
$(Verb) $(Link) -nostartfiles -Wl,-r -nodefaultlibs -o $@ \
|
||||||
|
-Wl,--whole-archive -lstdc++ \
|
||||||
|
-Wl,--no-whole-archive
|
||||||
|
# FIXME: workaround to invalidate -lstdc++
|
||||||
|
$(Echo) Making dummy -lstdc++ to lib
|
||||||
|
$(Verb) $(AR) rc $(ToolDir)/libstdc++.dll.a
|
||||||
|
# FIXME: Is install-local needed?
|
||||||
|
|
||||||
|
clean-local::
|
||||||
|
$(Verb) $(RM) -f $(ToolDir)/libstdc++.dll.a
|
||||||
|
|
||||||
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user