llvm.org GIT mirror llvm / e55db74
The attached patches attempt to fix cross builds. For example, if you try to use i686-darwin to build for arm-eabi, you'll quickly run into several false assumptions that the target OS must be the same as the host OS. These patches split $(OS) into $(HOST_OS) and $(TARGET_OS) to help builds like "make check" and the test-suite able to cross compile. Along the way a target of *-unknown-eabi is defined as "Freestanding" so that TARGET_OS checks have something to work with. Patch by Sandeep Patel! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79296 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 10 years ago
9 changed file(s) with 83 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
8888 LLVM_ON_UNIX:=@LLVM_ON_UNIX@
8989 LLVM_ON_WIN32:=@LLVM_ON_WIN32@
9090
91 # Target operating system for which LLVM will be compiled.
91 # Host operating system for which LLVM will be run.
9292 OS=@OS@
93 HOST_OS=@HOST_OS@
94 # Target operating system for which LLVM will compile for.
95 TARGET_OS=@TARGET_OS@
9396
9497 # Target hardware architecture
9598 ARCH=@ARCH@
127130
128131 # Path to the library archiver program.
129132 AR_PATH = @AR@
133 AR = @AR@
130134
131135 # Path to the nm program
132136 NM_PATH = @NM@
286286 # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
287287 # this can be overridden on the make command line.
288288 ifndef OPTIMIZE_OPTION
289 ifneq ($(OS),MingW)
289 ifneq ($(HOST_OS),MingW)
290290 OPTIMIZE_OPTION := -O3
291291 else
292292 OPTIMIZE_OPTION := -O2
296296 ifeq ($(ENABLE_OPTIMIZED),1)
297297 BuildMode := Release
298298 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
299 ifneq ($(OS),FreeBSD)
300 ifneq ($(OS),Darwin)
299 ifneq ($(HOST_OS),FreeBSD)
300 ifneq ($(HOST_OS),Darwin)
301301 OmitFramePointer := -fomit-frame-pointer
302302 endif
303303 endif
305305 # Darwin requires -fstrict-aliasing to be explicitly enabled.
306306 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
307307 # with -fstrict-aliasing and ipa-type-escape radr://6756684
308 #ifeq ($(OS),Darwin)
308 #ifeq ($(HOST_OS),Darwin)
309309 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
310310 #endif
311311 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
378378 endif
379379
380380 ifeq ($(ENABLE_PIC),1)
381 ifeq ($(OS), $(filter $(OS), Cygwin MingW))
381 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
382382 # Nothing. Win32 defaults to PIC and warns when given -fPIC
383383 else
384 ifeq ($(OS),Darwin)
384 ifeq ($(HOST_OS),Darwin)
385385 # Common symbols not allowed in dylib files
386386 CXX.Flags += -fno-common
387387 C.Flags += -fno-common
392392 endif
393393 endif
394394 else
395 ifeq ($(OS),Darwin)
395 ifeq ($(HOST_OS),Darwin)
396396 CXX.Flags += -mdynamic-no-pic
397397 C.Flags += -mdynamic-no-pic
398398 endif
419419 LD.Flags += -Wl,--no-relax
420420 endif
421421
422 ifeq ($(OS),MingW)
422 ifeq ($(HOST_OS),MingW)
423423 ifeq ($(LLVM_CROSS_COMPILING),1)
424424 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
425425 ifdef TOOLNAME
501501 # Adjust to user's request
502502 #--------------------------------------------------------------------
503503
504 ifeq ($(OS),Darwin)
504 ifeq ($(HOST_OS),Darwin)
505505 DARWIN_VERSION := `sw_vers -productVersion`
506506 # Strip a number like 10.4.7 to 10.4
507507 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
510510
511511 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
512512 -dynamiclib -mmacosx-version-min=$(DARWIN_VERSION)
513 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
514 else
515 ifeq ($(OS),Cygwin)
513 else
514 ifeq ($(HOST_OS),Cygwin)
516515 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
517516 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
518517 else
520519 endif
521520 endif
522521
522 ifeq ($(TARGET_OS),Darwin)
523 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
524 endif
525
523526 # Adjust LD.Flags depending on the kind of library that is to be built. Note
524527 # that if LOADABLE_MODULE is specified then the resulting shared library can
525528 # be opened with dlopen.
557560 endif
558561
559562 # Adjust linker flags for building an executable
560 ifneq ($(OS),Darwin)
563 ifneq ($(HOST_OS),Darwin)
561564 ifneq ($(DARWIN_MAJVERS),4)
562565 ifdef TOOLNAME
563566 ifdef EXAMPLE_TOOL
579582 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
580583 $(EXTRA_OPTIONS)
581584
582 ifeq ($(OS),HP-UX)
585 ifeq ($(HOST_OS),HP-UX)
583586 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
584587 endif
585588
607610 # Building universal cannot compute dependencies automatically.
608611 DISABLE_AUTO_DEPENDENCIES=1
609612 else
610 ifeq ($(OS),Darwin)
613 ifeq ($(TARGET_OS),Darwin)
611614 ifeq ($(ARCH),x86_64)
612615 TargetCommonOpts = -m64
613616 else
618621 endif
619622 endif
620623
621 ifeq ($(OS),SunOS)
624 ifeq ($(HOST_OS),SunOS)
622625 CPP.BaseFlags += -include llvm/System/Solaris.h
623626 endif
624627
11711174 # not exporting all of the weak symbols from the binary. This reduces dyld
11721175 # startup time by 4x on darwin in some cases.
11731176 ifdef TOOL_NO_EXPORTS
1174 ifeq ($(OS),Darwin)
1177 ifeq ($(HOST_OS),Darwin)
11751178
11761179 # Tiger tools don't support this.
11771180 ifneq ($(DARWIN_MAJVERS),4)
11791182 endif
11801183 endif
11811184
1182 ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
1185 ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
11831186 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
11841187 endif
11851188 endif
12331236 ###############################################################################
12341237
12351238 # FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1236 ifeq ($(OS),HP-UX)
1239 ifeq ($(HOST_OS),HP-UX)
12371240 DISABLE_AUTO_DEPENDENCIES=1
12381241 endif
12391242
174174 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
175175 llvm_cv_os_type="MingW"
176176 llvm_cv_platform_type="Win32" ;;
177 *-unknown-eabi*)
178 llvm_cv_link_all_option="-Wl,--whole-archive"
179 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
180 llvm_cv_os_type="Freestanding"
181 llvm_cv_platform_type="Unix" ;;
182 *-unknown-elf*)
183 llvm_cv_link_all_option="-Wl,--whole-archive"
184 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
185 llvm_cv_os_type="Freestanding"
186 llvm_cv_platform_type="Unix" ;;
177187 *)
178188 llvm_cv_link_all_option=""
179189 llvm_cv_no_link_all_option=""
181191 llvm_cv_platform_type="Unknown" ;;
182192 esac])
183193
194 AC_CACHE_CHECK([type of operating system we're going to target],
195 [llvm_cv_target_os_type],
196 [case $target in
197 *-*-aix*)
198 llvm_cv_target_os_type="AIX" ;;
199 *-*-irix*)
200 llvm_cv_target_os_type="IRIX" ;;
201 *-*-cygwin*)
202 llvm_cv_target_os_type="Cygwin" ;;
203 *-*-darwin*)
204 llvm_cv_target_os_type="Darwin" ;;
205 *-*-freebsd*)
206 llvm_cv_target_os_type="FreeBSD" ;;
207 *-*-openbsd*)
208 llvm_cv_target_os_type="OpenBSD" ;;
209 *-*-netbsd*)
210 llvm_cv_target_os_type="NetBSD" ;;
211 *-*-dragonfly*)
212 llvm_cv_target_os_type="DragonFly" ;;
213 *-*-hpux*)
214 llvm_cv_target_os_type="HP-UX" ;;
215 *-*-interix*)
216 llvm_cv_target_os_type="Interix" ;;
217 *-*-linux*)
218 llvm_cv_target_os_type="Linux" ;;
219 *-*-solaris*)
220 llvm_cv_target_os_type="SunOS" ;;
221 *-*-win32*)
222 llvm_cv_target_os_type="Win32" ;;
223 *-*-mingw*)
224 llvm_cv_target_os_type="MingW" ;;
225 *-unknown-eabi*)
226 llvm_cv_target_os_type="Freestanding" ;;
227 *)
228 llvm_cv_target_os_type="Unknown" ;;
229 esac])
230
184231 dnl Make sure we aren't attempting to configure for an unknown system
185232 if test "$llvm_cv_os_type" = "Unknown" ; then
186233 AC_MSG_ERROR([Operating system is unknown, configure can't continue])
189236 dnl Set the "OS" Makefile variable based on the platform type so the
190237 dnl makefile can configure itself to specific build hosts
191238 AC_SUBST(OS,$llvm_cv_os_type)
239 AC_SUBST(HOST_OS,$llvm_cv_os_type)
240 AC_SUBST(TARGET_OS,$llvm_cv_target_os_type)
192241
193242 dnl Set the LINKALL and NOLINKALL Makefile variables based on the platform
194243 AC_SUBST(LINKALL,$llvm_cv_link_all_option)
1212 include $(LEVEL)/Makefile.config
1313
1414 # No support for plugins on windows targets
15 ifeq ($(OS), $(filter $(OS), Cygwin MingW))
15 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1616 PARALLEL_DIRS := $(filter-out Hello, $(PARALLEL_DIRS))
1717 endif
1818
5252 endif
5353
5454 # Both AuroraUX & Solaris do not have the -m flag for ulimit
55 ifeq ($(OS),SunOS)
55 ifeq ($(HOST_OS),SunOS)
5656 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
5757 else
5858 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -m 512000 ; ulimit -v 512000 ;
9292 $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
9393
9494 # dsymutil is used on the Darwin to manipulate DWARF debugging information.
95 ifeq ($(OS),Darwin)
95 ifeq ($(TARGET_OS),Darwin)
9696 DSYMUTIL=dsymutil
9797 else
9898 DSYMUTIL=true
7272 }
7373
7474 set retval [ catch {
75 exec -keepnewline gcc -g -D__STDC_LIMIT_MACROS -o $executable $generated -I$srcroot/include -I$objroot/include -L$llvmlibsdir -lLLVMCore -lLLVMSupport -lLLVMbzip2 -lLLVMSystem -lstdc++ } msg ]
75 exec -keepnewline gcc -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -o $executable $generated -I$srcroot/include -I$objroot/include -L$llvmlibsdir -lLLVMCore -lLLVMSupport -lLLVMSystem -lstdc++ } msg ]
7676 if { $retval != 0 } {
7777 fail "$test: gcc returned $retval\n$msg"
7878 continue
3838 endif
3939
4040 # No support for lto / gold on windows targets
41 ifeq ($(OS), $(filter $(OS), Cygwin MingW))
41 ifeq ($(TARGET_OS), $(filter $(TARGET_OS), Cygwin MingW))
4242 DIRS := $(filter-out lto gold, $(DIRS))
4343 endif
4444
2121
2222 include $(LEVEL)/Makefile.common
2323
24 ifeq ($(OS),Darwin)
24 ifeq ($(HOST_OS),Darwin)
2525 # set dylib internal version number to llvmCore submission number
2626 ifdef LLVM_SUBMIT_VERSION
2727 LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \
1717 CPP.Flags += -I$(LLVM_SRC_ROOT)/utils/unittest/googletest/include
1818 CPP.Flags += $(NO_MISSING_FIELD_INITIALIZERS) $(NO_VARIADIC_MACROS)
1919
20 ifeq ($(OS),MingW)
20 ifeq ($(HOST_OS),MingW)
2121 CPP.Flags += -DGTEST_OS_WINDOWS=1
2222 endif
2323