llvm.org GIT mirror llvm / 1a9e248
Remove dead code from the makefile build system. Back in r140220 we removed the autoconf code that would set LLVMCC_OPTION since it was only used by the test-suite. This patch now removes code that would only be used if LLVMCC_OPTION was set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187154 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
5 changed file(s) with 96 addition(s) and 640 deletion(s). Raw diff Collapse all Expand all
4141 # Reset the list of suffixes we know how to build.
4242 #--------------------------------------------------------------------
4343 .SUFFIXES:
44 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll .m .mm
44 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .td .ps .dot .m .mm
4545 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
4646
4747 #--------------------------------------------------------------------
496496 SharedPrefix := cyg
497497 else
498498 SharedPrefix :=
499 endif
500 endif
501
502 #--------------------------------------------------------------------
503 # LLVM Capable Compiler
504 #--------------------------------------------------------------------
505
506 ifneq ($(findstring llvm-gcc,$(LLVMCC_OPTION)),)
507 LLVMCC := $(LLVMGCC)
508 LLVMCXX := $(LLVMGXX)
509 else
510 ifneq ($(findstring clang,$(LLVMCC_OPTION)),)
511 ifneq ($(CLANGPATH),)
512 LLVMCC := $(CLANGPATH)
513 LLVMCXX := $(CLANGXXPATH)
514 else
515 ifeq ($(ENABLE_BUILT_CLANG),1)
516 LLVMCC := $(LLVMToolDir)/clang
517 LLVMCXX := $(LLVMToolDir)/clang++
518 endif
519 endif
520499 endif
521500 endif
522501
761740 $(CXX) $(CXXFLAGS) $(LD.Flags) $(LDFLAGS) \
762741 $(TargetCommonOpts) $(Strip)
763742
764 BCCompile.C = $(LLVMCC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
765 $(TargetCommonOpts) $(CompileCommonOpts)
766743 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
767744 $(TargetCommonOpts) $(CompileCommonOpts) -E
768
769 BCCompile.CXX = $(LLVMCXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
770 $(TargetCommonOpts) $(CompileCommonOpts)
771745
772746 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
773747 ScriptInstall = $(INSTALL) -m 0755
783757 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
784758
785759 Archive = $(AR) $(AR.Flags)
786 LArchive = $(LLVMToolDir)/llvm-ar rcsf
787760 ifdef RANLIB
788761 Ranlib = $(RANLIB)
789762 else
811784 BaseNameSources := $(sort $(basename $(Sources)))
812785
813786 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
814 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
815787
816788 #----------------------------------------------------------
817789 # For Mingw MSYS bash and Python/w32:
11391111 # Library Build Rules: Four ways to build a library
11401112 ###############################################################################
11411113
1142 #---------------------------------------------------------
1143 # Bytecode Module Targets:
1144 # If the user set MODULE_NAME then they want to build a
1145 # bytecode module from the sources. We compile all the
1146 # sources and link it together into a single bytecode
1147 # module.
1148 #---------------------------------------------------------
1149
1150 ifdef MODULE_NAME
1151 ifeq ($(strip $(LLVMCC)),)
1152 $(warning Modules require LLVM capable compiler but none is available ****)
1153 else
1154
1155 Module := $(LibDir)/$(MODULE_NAME).bc
1156 LinkModule := $(LLVMLINK)
1157
1114 # if we're building a library ...
1115 ifdef LIBRARYNAME
1116
1117 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1118 LIBRARYNAME := $(strip $(LIBRARYNAME))
1119 ifdef LOADABLE_MODULE
1120 BaseLibName.A := $(LIBRARYNAME).a
1121 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1122 else
1123 BaseLibName.A := lib$(LIBRARYNAME).a
1124 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1125 endif
1126 LibName.A := $(LibDir)/$(BaseLibName.A)
1127 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1128 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1129
1130 #---------------------------------------------------------
1131 # Shared Library Targets:
1132 # If the user asked for a shared library to be built
1133 # with the SHARED_LIBRARY variable, then we provide
1134 # targets for building them.
1135 #---------------------------------------------------------
1136 ifdef SHARED_LIBRARY
1137
1138 all-local:: $(LibName.SO)
11581139
11591140 ifdef EXPORTED_SYMBOL_FILE
1160 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1161 endif
1162
1163 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLINK)
1164 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
1165 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
1166
1167 all-local:: $(Module)
1141 $(LibName.SO): $(NativeExportsFile)
1142 endif
1143
1144 ifdef LINK_LIBS_IN_SHARED
1145 ifdef LOADABLE_MODULE
1146 SharedLibKindMessage := "Loadable Module"
1147 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1148 else
1149 SharedLibKindMessage := "Shared Library"
1150 endif
1151 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1152 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1153 $(notdir $@)
1154 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1155 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1156 else
1157 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1158 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1159 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1160 endif
11681161
11691162 clean-local::
1170 ifneq ($(strip $(Module)),)
1171 -$(Verb) $(RM) -f $(Module)
1172 endif
1173
1174 ifdef BYTECODE_DESTINATION
1175 ModuleDestDir := $(BYTECODE_DESTINATION)
1176 else
1177 ModuleDestDir := $(DESTDIR)$(PROJ_libdir)
1163 ifneq ($(strip $(LibName.SO)),)
1164 -$(Verb) $(RM) -f $(LibName.SO)
11781165 endif
11791166
11801167 ifdef NO_INSTALL
11831170 uninstall-local::
11841171 $(Echo) Uninstall circumvented with NO_INSTALL
11851172 else
1186 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
1187
1188 install-module:: $(DestModule)
1189 install-local:: $(DestModule)
1190
1191 $(DestModule): $(ModuleDestDir) $(Module)
1192 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
1193 $(Verb) $(DataInstall) $(Module) $(DestModule)
1194
1195 uninstall-local::
1196 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1197 -$(Verb) $(RM) -f $(DestModule)
1198 endif
1199
1200 endif
1201 endif
1202
1203 # if we're building a library ...
1204 ifdef LIBRARYNAME
1205
1206 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1207 LIBRARYNAME := $(strip $(LIBRARYNAME))
1208 ifdef LOADABLE_MODULE
1209 BaseLibName.A := $(LIBRARYNAME).a
1210 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1211 else
1212 BaseLibName.A := lib$(LIBRARYNAME).a
1213 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1214 endif
1215 LibName.A := $(LibDir)/$(BaseLibName.A)
1216 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1217 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1218 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
1219
1220 #---------------------------------------------------------
1221 # Shared Library Targets:
1222 # If the user asked for a shared library to be built
1223 # with the SHARED_LIBRARY variable, then we provide
1224 # targets for building them.
1225 #---------------------------------------------------------
1226 ifdef SHARED_LIBRARY
1227
1228 all-local:: $(LibName.SO)
1229
1230 ifdef EXPORTED_SYMBOL_FILE
1231 $(LibName.SO): $(NativeExportsFile)
1232 endif
1233
1234 ifdef LINK_LIBS_IN_SHARED
1235 ifdef LOADABLE_MODULE
1236 SharedLibKindMessage := "Loadable Module"
1237 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1238 else
1239 SharedLibKindMessage := "Shared Library"
1240 endif
1241 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1242 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1243 $(notdir $@)
1244 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1245 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1246 else
1247 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1248 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1249 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1250 endif
1251
1252 clean-local::
1253 ifneq ($(strip $(LibName.SO)),)
1254 -$(Verb) $(RM) -f $(LibName.SO)
1255 endif
1256
1257 ifdef NO_INSTALL
1258 install-local::
1259 $(Echo) Install circumvented with NO_INSTALL
1260 uninstall-local::
1261 $(Echo) Uninstall circumvented with NO_INSTALL
1262 else
12631173
12641174 # Win32.DLL prefers to be located on the "PATH" of binaries.
12651175 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
12781188 uninstall-local::
12791189 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
12801190 -$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
1281 endif
1282 endif
1283
1284 #---------------------------------------------------------
1285 # Bytecode Library Targets:
1286 # If the user asked for a bytecode library to be built
1287 # with the BYTECODE_LIBRARY variable, then we provide
1288 # targets for building them.
1289 #---------------------------------------------------------
1290 ifdef BYTECODE_LIBRARY
1291 ifeq ($(strip $(LLVMCC)),)
1292 $(warning Bytecode libraries require LLVM capable compiler but none is available ****)
1293 else
1294
1295 all-local:: $(LibName.BCA)
1296
1297 ifdef EXPORTED_SYMBOL_FILE
1298 BCLinkLib = $(LLVMLINK) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1299
1300 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLINK) \
1301 $(LLVMToolDir)/llvm-ar
1302 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1303 "(internalize)"
1304 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1305 $(Verb) $(RM) -f $@
1306 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1307 else
1308 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1309 $(LLVMToolDir)/llvm-ar
1310 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1311 $(Verb) $(RM) -f $@
1312 $(Verb) $(LArchive) $@ $(ObjectsBC)
1313
1314 endif
1315
1316 clean-local::
1317 ifneq ($(strip $(LibName.BCA)),)
1318 -$(Verb) $(RM) -f $(LibName.BCA)
1319 endif
1320
1321 ifdef BYTECODE_DESTINATION
1322 BytecodeDestDir := $(BYTECODE_DESTINATION)
1323 else
1324 BytecodeDestDir := $(DESTDIR)$(PROJ_libdir)
1325 endif
1326
1327 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1328
1329 install-bytecode-local:: $(DestBytecodeLib)
1330
1331 ifdef NO_INSTALL
1332 install-local::
1333 $(Echo) Install circumvented with NO_INSTALL
1334 uninstall-local::
1335 $(Echo) Uninstall circumvented with NO_INSTALL
1336 else
1337 install-local:: $(DestBytecodeLib)
1338
1339 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1340 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1341 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1342
1343 uninstall-local::
1344 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1345 -$(Verb) $(RM) -f $(DestBytecodeLib)
1346 endif
13471191 endif
13481192 endif
13491193
16341478 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
16351479 $(DEPEND_MOVEFILE)
16361480
1637 #---------------------------------------------------------
1638 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1639 #---------------------------------------------------------
1640
1641 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1642 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1643
1644 # If the build succeeded, move the dependency file over, otherwise
1645 # remove it.
1646 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1647 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1648
1649 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1650 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1651 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1652 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1653 $(BC_DEPEND_MOVEFILE)
1654
1655 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1656 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1657 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1658 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1659 $(BC_DEPEND_MOVEFILE)
1660
1661 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1662 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1663 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1664 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1665 $(BC_DEPEND_MOVEFILE)
1666
1667 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1668 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1669 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1670 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1671 $(BC_DEPEND_MOVEFILE)
1672
1673 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1674 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1675 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1676 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1677 $(BC_DEPEND_MOVEFILE)
1678
16791481 # Provide alternate rule sets if dependencies are disabled
16801482 else
16811483
16981500 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
16991501 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
17001502 $(Compile.C) $< -o $@
1701
1702 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1703 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1704 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1705
1706 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1707 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1708 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1709
1710 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1711 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1712 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1713
1714 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1715 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1716 $(BCCompile.C) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1717
1718 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1719 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1720 $(BCCompile.C) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1721
17221503 endif
17231504
17241505
17631544 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
17641545 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
17651546 $(Compile.C) $< -o $@ -S
1766
1767
1768 # make the C and C++ compilers strip debug info out of bytecode libraries.
1769 ifdef DEBUG_RUNTIME
1770 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1771 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1772 $(Verb) $(LOPT) $< -std-compile-opts -o $@
1773 else
1774 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1775 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1776 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1777 endif
1778
1779
1780 #---------------------------------------------------------
1781 # Provide rule to build .bc files from .ll sources,
1782 # regardless of dependencies
1783 #---------------------------------------------------------
1784 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1785 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1786 $(Verb) $(LLVMAS) $< -f -o $@
17871547
17881548 ###############################################################################
17891549 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
19511711 # Get the list of dependency files
19521712 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
19531713 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1954
1955 # Include bitcode dependency files if using bitcode libraries
1956 ifdef BYTECODE_LIBRARY
1957 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1958 endif
19591714
19601715 -include $(DependFiles) ""
19611716
170170 intend to be loaded into an tool via the ``-load`` option. `Pass documentation
171171 `_ has an example of why you might want to do
172172 this.
173
174 Bitcode Modules
175 ^^^^^^^^^^^^^^^
176
177 In some situations, it is desirable to build a single bitcode module from a
178 variety of sources, instead of an archive, shared library, or bitcode
179 library. Bitcode modules can be specified in addition to any of the other types
180 of libraries by defining the `MODULE_NAME`_ variable. For example:
181
182 .. code-block:: makefile
183
184 LIBRARYNAME = mylib
185 BYTECODE_LIBRARY = 1
186 MODULE_NAME = mymod
187
188 will build a module named ``mymod.bc`` from the sources in the directory. This
189 module will be an aggregation of all the bitcode modules derived from the
190 sources. The example will also build a bitcode archive containing a bitcode
191 module for each compiled source file. The difference is subtle, but important
192 depending on how the module or library is to be linked.
193173
194174 Loadable Modules
195175 ^^^^^^^^^^^^^^^^
485465 files. These sources will be built before any other target processing to
486466 ensure they are present.
487467
488 ``BYTECODE_LIBRARY``
489 If set to any value, causes a bitcode library (.bc) to be built.
490
491468 ``CONFIG_FILES``
492469 Specifies a set of configuration files to be installed.
493470
589566 setting this variable without also setting ``SHARED_LIBRARY`` will have no
590567 effect.
591568
592 .. _MODULE_NAME:
593
594 ``MODULE_NAME``
595 Specifies the name of a bitcode module to be created. A bitcode module can
596 be specified in conjunction with other kinds of library builds or by
597 itself. It constructs from the sources a single linked bitcode file.
598
599569 ``NO_INSTALL``
600570 Specifies that the build products of the directory should not be installed
601571 but should be built even if the ``install`` target is given. This is handy
738708 ``LLVMAS`` (defaulted)
739709 Specifies the path to the ``llvm-as`` tool.
740710
741 ``LLVMCC``
742 Specifies the path to the LLVM capable compiler.
743
744 ``LLVMCXX``
745 Specifies the path to the LLVM C++ capable compiler.
746
747711 ``LLVMGCC`` (defaulted)
748712 Specifies the path to the LLVM version of the GCC 'C' Compiler.
749713
887851 Archive
888852 AR.Flags
889853 BaseNameSources
890 BCCompile.C
891 BCCompile.CXX
892854 BCLinkLib
893855 C.Flags
894856 Compile.C
935897 LLVMUsedLibs
936898 LocalTargets
937899 Module
938 ObjectsBC
939900 ObjectsLO
940901 ObjectsO
941902 ObjMakefiles
4141 # Reset the list of suffixes we know how to build.
4242 #--------------------------------------------------------------------
4343 .SUFFIXES:
44 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll .m .mm
44 .SUFFIXES: .c .cpp .cc .h .hpp .o .a .td .ps .dot .m .mm
4545 .SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
4646
4747 #--------------------------------------------------------------------
433433 SharedPrefix := cyg
434434 else
435435 SharedPrefix :=
436 endif
437 endif
438
439 #--------------------------------------------------------------------
440 # LLVM Capable Compiler
441 #--------------------------------------------------------------------
442
443 ifneq ($(findstring llvm-gcc,$(LLVMCC_OPTION)),)
444 LLVMCC := $(LLVMGCC)
445 LLVMCXX := $(LLVMGXX)
446 else
447 ifneq ($(findstring clang,$(LLVMCC_OPTION)),)
448 ifneq ($(CLANGPATH),)
449 LLVMCC := $(CLANGPATH)
450 LLVMCXX := $(CLANGXXPATH)
451 else
452 ifeq ($(ENABLE_BUILT_CLANG),1)
453 LLVMCC := $(LLVMToolDir)/clang
454 LLVMCXX := $(LLVMToolDir)/clang++
455 endif
456 endif
457436 endif
458437 endif
459438
689668 $(LDFLAGS) $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
690669 endif
691670
692 BCCompile.C = $(LLVMCC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
693 $(TargetCommonOpts) $(CompileCommonOpts)
694671 Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
695672 $(TargetCommonOpts) $(CompileCommonOpts) -E
696
697 BCCompile.CXX = $(LLVMCXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
698 $(TargetCommonOpts) $(CompileCommonOpts)
699673
700674 ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
701675 ScriptInstall = $(INSTALL) -m 0755
711685 LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
712686
713687 Archive = $(AR) $(AR.Flags)
714 LArchive = $(LLVMToolDir)/llvm-ar rcsf
715688 ifdef RANLIB
716689 Ranlib = $(RANLIB)
717690 else
739712 BaseNameSources := $(sort $(basename $(Sources)))
740713
741714 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
742 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
743715
744716 #----------------------------------------------------------
745717 # For Mingw MSYS bash and Python/w32:
10601032 # Library Build Rules: Four ways to build a library
10611033 ###############################################################################
10621034
1063 #---------------------------------------------------------
1064 # Bytecode Module Targets:
1065 # If the user set MODULE_NAME then they want to build a
1066 # bytecode module from the sources. We compile all the
1067 # sources and link it together into a single bytecode
1068 # module.
1069 #---------------------------------------------------------
1070
1071 ifdef MODULE_NAME
1072 ifeq ($(strip $(LLVMCC)),)
1073 $(warning Modules require LLVM capable compiler but none is available ****)
1074 else
1075
1076 Module := $(LibDir)/$(MODULE_NAME).bc
1077 LinkModule := $(LLVMLD) -r
1078
1035 # if we're building a library ...
1036 ifdef LIBRARYNAME
1037
1038 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1039 LIBRARYNAME := $(strip $(LIBRARYNAME))
1040 ifdef LOADABLE_MODULE
1041 BaseLibName.A := $(LIBRARYNAME).a
1042 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1043 else
1044 BaseLibName.A := lib$(LIBRARYNAME).a
1045 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1046 endif
1047 LibName.A := $(LibDir)/$(BaseLibName.A)
1048 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1049 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1050
1051 #---------------------------------------------------------
1052 # Shared Library Targets:
1053 # If the user asked for a shared library to be built
1054 # with the SHARED_LIBRARY variable, then we provide
1055 # targets for building them.
1056 #---------------------------------------------------------
1057 ifdef SHARED_LIBRARY
1058
1059 all-local:: $(LibName.SO)
10791060
10801061 ifdef EXPORTED_SYMBOL_FILE
1081 LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1082 endif
1083
1084 $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
1085 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
1086 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
1087
1088 all-local:: $(Module)
1062 $(LibName.SO): $(NativeExportsFile)
1063 endif
1064
1065 ifdef LINK_LIBS_IN_SHARED
1066 ifdef LOADABLE_MODULE
1067 SharedLibKindMessage := "Loadable Module"
1068 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1069 else
1070 SharedLibKindMessage := "Shared Library"
1071 endif
1072 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1073 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1074 $(notdir $@)
1075 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1076 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1077 else
1078 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1079 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1080 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1081 endif
10891082
10901083 clean-local::
1091 ifneq ($(strip $(Module)),)
1092 -$(Verb) $(RM) -f $(Module)
1093 endif
1094
1095 ifdef BYTECODE_DESTINATION
1096 ModuleDestDir := $(BYTECODE_DESTINATION)
1097 else
1098 ModuleDestDir := $(DESTDIR)$(PROJ_libdir)
1084 ifneq ($(strip $(LibName.SO)),)
1085 -$(Verb) $(RM) -f $(LibName.SO)
10991086 endif
11001087
11011088 ifdef NO_INSTALL
11041091 uninstall-local::
11051092 $(Echo) Uninstall circumvented with NO_INSTALL
11061093 else
1107 DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
1108
1109 install-module:: $(DestModule)
1110 install-local:: $(DestModule)
1111
1112 $(DestModule): $(ModuleDestDir) $(Module)
1113 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
1114 $(Verb) $(DataInstall) $(Module) $(DestModule)
1115
1116 uninstall-local::
1117 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1118 -$(Verb) $(RM) -f $(DestModule)
1119 endif
1120
1121 endif
1122 endif
1123
1124 # if we're building a library ...
1125 ifdef LIBRARYNAME
1126
1127 # Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
1128 LIBRARYNAME := $(strip $(LIBRARYNAME))
1129 ifdef LOADABLE_MODULE
1130 BaseLibName.A := $(LIBRARYNAME).a
1131 BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
1132 else
1133 BaseLibName.A := lib$(LIBRARYNAME).a
1134 BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
1135 endif
1136 LibName.A := $(LibDir)/$(BaseLibName.A)
1137 LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
1138 LibName.O := $(LibDir)/$(LIBRARYNAME).o
1139 LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
1140
1141 #---------------------------------------------------------
1142 # Shared Library Targets:
1143 # If the user asked for a shared library to be built
1144 # with the SHARED_LIBRARY variable, then we provide
1145 # targets for building them.
1146 #---------------------------------------------------------
1147 ifdef SHARED_LIBRARY
1148
1149 all-local:: $(LibName.SO)
1150
1151 ifdef EXPORTED_SYMBOL_FILE
1152 $(LibName.SO): $(NativeExportsFile)
1153 endif
1154
1155 ifdef LINK_LIBS_IN_SHARED
1156 ifdef LOADABLE_MODULE
1157 SharedLibKindMessage := "Loadable Module"
1158 SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
1159 else
1160 SharedLibKindMessage := "Shared Library"
1161 endif
1162 $(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
1163 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1164 $(notdir $@)
1165 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
1166 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
1167 else
1168 $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
1169 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
1170 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
1171 endif
1172
1173 clean-local::
1174 ifneq ($(strip $(LibName.SO)),)
1175 -$(Verb) $(RM) -f $(LibName.SO)
1176 endif
1177
1178 ifdef NO_INSTALL
1179 install-local::
1180 $(Echo) Install circumvented with NO_INSTALL
1181 uninstall-local::
1182 $(Echo) Uninstall circumvented with NO_INSTALL
1183 else
11841094
11851095 # Win32.DLL prefers to be located on the "PATH" of binaries.
11861096 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
11991109 uninstall-local::
12001110 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
12011111 -$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
1202 endif
1203 endif
1204
1205 #---------------------------------------------------------
1206 # Bytecode Library Targets:
1207 # If the user asked for a bytecode library to be built
1208 # with the BYTECODE_LIBRARY variable, then we provide
1209 # targets for building them.
1210 #---------------------------------------------------------
1211 ifdef BYTECODE_LIBRARY
1212 ifeq ($(strip $(LLVMCC)),)
1213 $(warning Bytecode libraries require LLVM capable compiler but none is available ****)
1214 else
1215
1216 all-local:: $(LibName.BCA)
1217
1218 ifdef EXPORTED_SYMBOL_FILE
1219 BCLinkLib = $(LLVMLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1220
1221 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1222 $(LLVMToolDir)/llvm-ar
1223 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1224 "(internalize)"
1225 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
1226 $(Verb) $(RM) -f $@
1227 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
1228 else
1229 $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1230 $(LLVMToolDir)/llvm-ar
1231 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1232 $(Verb) $(RM) -f $@
1233 $(Verb) $(LArchive) $@ $(ObjectsBC)
1234
1235 endif
1236
1237 clean-local::
1238 ifneq ($(strip $(LibName.BCA)),)
1239 -$(Verb) $(RM) -f $(LibName.BCA)
1240 endif
1241
1242 ifdef BYTECODE_DESTINATION
1243 BytecodeDestDir := $(BYTECODE_DESTINATION)
1244 else
1245 BytecodeDestDir := $(DESTDIR)$(PROJ_libdir)
1246 endif
1247
1248 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
1249
1250 install-bytecode-local:: $(DestBytecodeLib)
1251
1252 ifdef NO_INSTALL
1253 install-local::
1254 $(Echo) Install circumvented with NO_INSTALL
1255 uninstall-local::
1256 $(Echo) Uninstall circumvented with NO_INSTALL
1257 else
1258 install-local:: $(DestBytecodeLib)
1259
1260 $(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
1261 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1262 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1263
1264 uninstall-local::
1265 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1266 -$(Verb) $(RM) -f $(DestBytecodeLib)
1267 endif
12681112 endif
12691113 endif
12701114
15351379 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
15361380 $(DEPEND_MOVEFILE)
15371381
1538 #---------------------------------------------------------
1539 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1540 #---------------------------------------------------------
1541
1542 BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1543 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1544
1545 # If the build succeeded, move the dependency file over, otherwise
1546 # remove it.
1547 BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1548 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1549
1550 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1551 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1552 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1553 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1554 $(BC_DEPEND_MOVEFILE)
1555
1556 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1557 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1558 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1559 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1560 $(BC_DEPEND_MOVEFILE)
1561
1562 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1563 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1564 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1565 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1566 $(BC_DEPEND_MOVEFILE)
1567
1568 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1569 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1570 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1571 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1572 $(BC_DEPEND_MOVEFILE)
1573
1574 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1575 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1576 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1577 $< -o $(ObjDir)/$*.ll -S $(LLVMCC_EMITIR_FLAG) ; \
1578 $(BC_DEPEND_MOVEFILE)
1579
15801382 # Provide alternate rule sets if dependencies are disabled
15811383 else
15821384
15991401 $(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
16001402 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
16011403 $(Compile.C) $< -o $@
1602
1603 $(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1604 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1605 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1606
1607 $(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1608 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1609 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1610
1611 $(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1612 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1613 $(BCCompile.CXX) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1614
1615 $(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1616 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1617 $(BCCompile.C) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1618
1619 $(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1620 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1621 $(BCCompile.C) $< -o $@ -S $(LLVMCC_EMITIR_FLAG)
1622
16231404 endif
16241405
16251406
16641445 $(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
16651446 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
16661447 $(Compile.C) $< -o $@ -S
1667
1668
1669 # make the C and C++ compilers strip debug info out of bytecode libraries.
1670 ifdef DEBUG_RUNTIME
1671 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1672 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1673 $(Verb) $(LOPT) $< -std-compile-opts -o $@
1674 else
1675 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
1676 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1677 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
1678 endif
1679
1680
1681 #---------------------------------------------------------
1682 # Provide rule to build .bc files from .ll sources,
1683 # regardless of dependencies
1684 #---------------------------------------------------------
1685 $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1686 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1687 $(Verb) $(LLVMAS) $< -f -o $@
16881448
16891449 ###############################################################################
16901450 # TABLEGEN: Provide rules for running tblgen to produce *.inc files
18551615 # Get the list of dependency files
18561616 DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
18571617 DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1858
1859 # Include bitcode dependency files if using bitcode libraries
1860 ifdef BYTECODE_LIBRARY
1861 DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1862 endif
18631618
18641619 -include $(DependFiles) ""
18651620
99 LEVEL = ../..
1010 include $(LEVEL)/Makefile.config
1111
12 ifneq ($(strip $(LLVMCC)),)
13 BYTECODE_LIBRARY = 1
14 endif
1512 LIBRARYNAME = profile_rt
1613 LINK_LIBS_IN_SHARED = 1
1714 SHARED_LIBRARY = 1
4646 $(RM) -f a.out core
4747 $(RM) -rf Output/
4848
49 # Compile from X.c to Output/X.ll
50 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
51 -$(LLVMCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
52
53 # Compile from X.cpp to Output/X.ll
54 Output/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
55 -$(LLVMCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
56
57 # Compile from X.cc to Output/X.ll
58 Output/%.ll: %.cc $(LCC1XX) Output/.dir $(INCLUDES)
59 -$(LLVMCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
60
6149 # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
6250 # from GCC output, so use GCCAS.
6351 #