<div>
<div><span class="gmail_quote">On 8/3/06, <b class="gmail_sendername">Anton Korobeynikov</b> <<a href="mailto:asl@math.spbu.ru">asl@math.spbu.ru</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hello Anton<br><br>Thu, 3 Aug 2006 12:38:54 +0400 you wrote:<br><br>> I've updated it yesterday and rebuilt - llvm built fine. But when
<br>> building llvm-gcc4 (also updated yesterday from new /trunk<br>> directory) it fails with the same error.<br>You might easily get llvm-gcc4-mingw32 binaries from "prerelease"<br>directory. Since stdcall, fastcall & dllimport stuff is unsupported
<br>right now, I don't see too much difference between cygwin & mingw<br>builds of llvm-gcc except the extended file names support of the former<br>(e.g. it can accept "/home/user/foo.c").<br><br>Could you please show us the contents of your llvm-confg file (it
<br>should be in your /llvm/obj/Debug/bin/)</blockquote>
<div> </div>
<div>here it is:</div></div></div>
<div> </div>
<div>#!/usr/bin/perl<br>##===- tools/llvm-config ---------------------------------------*- perl -*-===##<br># <br># The LLVM Compiler Infrastructure<br>#<br># This file was developed by Eric Kidd and is distributed under
<br># the University of Illinois Open Source License. See LICENSE.TXT for details.<br># <br>##===----------------------------------------------------------------------===##<br>#<br># Synopsis: Prints out compiler options needed to build against an installed
<br># copy of LLVM.<br>#<br># Syntax: llvm-config OPTIONS... [COMPONENTS...]<br># <br>##===----------------------------------------------------------------------===##</div>
<div>
<p>use 5.006;<br>use strict;<br>use warnings;</p>
<p>#---- begin autoconf values ----<br>my $PACKAGE_NAME = q{llvm};<br>my $VERSION = q{1.9cvs};<br>my $PREFIX = q{/usr/local};<br>my $LLVM_CONFIGTIME = q{Wed Aug 2 20:17:41 RST 2006};<br>
my $LLVM_SRC_ROOT = q{/llvm/obj/tools/llvm-config/../../..};<br>my $LLVM_OBJ_ROOT = q{/llvm/obj/tools/llvm-config/../../.};<br>my $LLVM_ON_WIN32 = q{0};<br>my $LLVM_ON_UNIX = q{1};<br>my $LLVMGCCDIR = q{/llvm-gcc3/install};
<br>my $LLVMGCC = q{/llvm-gcc3/install/bin/llvm-gcc.exe};<br>my $LLVMGXX = q{/llvm-gcc3/install/bin/llvm-g++.exe};<br>my $LLVMGCC_VERSION = q{3.4};<br>my $LLVMGCC_MAJVERS = q{3};<br>my $ENDIAN = q{little};
<br>my $SHLIBEXT = q{.dll};<br>my $EXEEXT = q{.exe};<br>my $OS = q{Cygwin};<br>my $ARCH = lc(q{x86});<br>my $TARGET_TRIPLE = q{i686-pc-cygwin};<br>my $TARGETS_TO_BUILD = q{CBackend X86 Sparc PowerPC Alpha IA64 ARM};
<br>my $TARGET_HAS_JIT = q{1};<br>my @TARGETS_BUILT = map { lc($_) } qw{CBackend X86 Sparc PowerPC Alpha IA64 ARM};<br>#---- end autoconf values ----</p>
<p>#---- begin Makefile values ----<br>my $CXXFLAGS = q{ -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -g -D_DEBUG };<br>my $LDFLAGS = q{};<br>my $SYSTEM_LIBS = q{-lpthread -lm };<br>my $LLVM_BUILDMODE = q{Debug};
<br>#---- end Makefile values ----</p>
<p># Figure out where llvm-config is being run from. Primarily, we care if it has<br># been installed, or is running from the build directory, which changes the<br># locations of some files.</p>
<p># Convert the current executable name into its directory (e.g. ".").<br>my ($RUN_DIR) = ($0 =~ /^(.*)\/.*$/);</p>
<p># Turn the directory into an absolute directory on the file system, also pop up<br># from "bin" into the build or prefix dir.<br>my $ABS_RUN_DIR = `cd $RUN_DIR/..; pwd`;<br>chomp($ABS_RUN_DIR);</p>
<p># Compute the absolute object directory build, e.g. "foo/llvm/Debug".<br>my $ABS_OBJ_ROOT = "$LLVM_OBJ_ROOT/$LLVM_BUILDMODE";<br>$ABS_OBJ_ROOT = `cd $ABS_OBJ_ROOT; pwd` if (-d $ABS_OBJ_ROOT);<br>chomp($ABS_OBJ_ROOT);
</p>
<p>my $INCLUDEDIR = "$ABS_RUN_DIR/include";<br>my $LIBDIR = "$ABS_RUN_DIR/lib";<br>my $BINDIR = "$ABS_RUN_DIR/bin";<br>if ($ABS_RUN_DIR eq $ABS_OBJ_ROOT) {<br> # If we are running out of the build directory, the include dir is in the
<br> # srcdir.<br> $INCLUDEDIR = "$LLVM_SRC_ROOT/include";<br>} else {<br> # If installed, ignore the prefix the tree was configured with, use the<br> # current prefix.<br> $PREFIX = $ABS_RUN_DIR;<br>}</p>
<p>sub usage;<br>sub fix_library_names (@);<br>sub fix_library_files (@);<br>sub expand_dependecies (@);<br>sub name_map_entries;</p>
<p># Parse our command-line arguments.<br>usage if @ARGV == 0;<br>my @components;<br>my $has_opt = 0;<br>my $want_libs = 0;<br>my $want_libnames = 0;<br>my $want_libfiles = 0;<br>my $want_components = 0;<br>foreach my $arg (@ARGV) {
<br> if ($arg =~ /^-/) {<br> if ($arg eq "--version") {<br> $has_opt = 1; print "$VERSION\n";<br> } elsif ($arg eq "--prefix") {<br> $has_opt = 1; print "$PREFIX\n";
<br> } elsif ($arg eq "--bindir") {<br> $has_opt = 1; print "$BINDIR\n";<br> } elsif ($arg eq "--includedir") {<br> $has_opt = 1; print "$INCLUDEDIR\n";
<br> } elsif ($arg eq "--libdir") {<br> $has_opt = 1; print "$LIBDIR\n";<br> } elsif ($arg eq "--cxxflags") {<br> $has_opt = 1; print "-I$INCLUDEDIR $CXXFLAGS\n";
<br> } elsif ($arg eq "--ldflags") {<br> $has_opt = 1; print "-L$LIBDIR $LDFLAGS $SYSTEM_LIBS\n";<br> } elsif ($arg eq "--libs") {<br> $has_opt = 1; $want_libs = 1;
<br> } elsif ($arg eq "--libnames") {<br> $has_opt = 1; $want_libnames = 1;<br> } elsif ($arg eq "--libfiles") {<br> $has_opt = 1; $want_libfiles = 1;<br> } elsif ($arg eq "--components") {
<br> $has_opt = 1; print join(' ', name_map_entries), "\n";<br> } elsif ($arg eq "--targets-built") {<br> $has_opt = 1; print join(' ', @TARGETS_BUILT), "\n";<br>
} elsif ($arg eq "--build-mode") {<br> $has_opt = 1; print "$LLVM_BUILDMODE\n";<br> } elsif ($arg eq "--obj-root") {<br> $has_opt = 1; print `cd $LLVM_OBJ_ROOT/; pwd` . "\n";
<br> } elsif ($arg eq "--src-root") {<br> $has_opt = 1; print `cd $LLVM_SRC_ROOT/; pwd` . "\n";<br> } else {<br> usage();<br> }<br> } else {<br> push @components, $arg;
<br> }<br>}</p>
<p># If no options were specified, fail.<br>usage unless $has_opt;</p>
<p># If no components were specified, default to 'all'.<br>if (@components == 0) {<br> push @components, 'all';<br>}</p>
<p># Handle any arguments which require building our dependency graph.<br>if ($want_libs || $want_libnames || $want_libfiles) {<br> my @libs = expand_dependecies(@components);<br> print join(' ', fix_library_names(@libs)), "\n" if ($want_libs);
<br> print join(' ', @libs), "\n" if ($want_libnames);<br> print join(' ', fix_library_files(@libs)), "\n" if ($want_libfiles);<br>}</p>
<p>exit 0;</p>
<p>#==========================================================================<br># Support Routines<br>#==========================================================================</p>
<p>sub usage {<br> print STDERR <<__EOD__;<br>Usage: llvm-config <OPTION>... [<COMPONENT>...]</p>
<p>Get various configuration information needed to compile programs which use<br>LLVM. Typically called from 'configure' scripts. Examples:<br> llvm-config --cxxflags<br> llvm-config --ldflags<br> llvm-config --libs engine bcreader scalaropts
</p>
<p>Options:<br> --version Print LLVM version.<br> --prefix Print the installation prefix.<br> --src-root Print the source root LLVM was built from.<br> --obj-root Print the object root used to build LLVM.
<br> --bindir Directory containing LLVM executables.<br> --includedir Directory containing LLVM headers.<br> --libdir Directory containing LLVM libraries.<br> --cxxflags C++ compiler flags for files that include LLVM headers.
<br> --ldflags Print Linker flags.<br> --libs Libraries needed to link against LLVM components.<br> --libnames Bare library names for in-tree builds.<br> --libfiles Fully qualified library filenames for makefile depends.
<br> --components List of all possible components.<br> --targets-built List of all targets currently built.<br> --build-mode Print build mode of LLVM tree (e.g. Debug or Release).<br>Typical components:
<br> all All LLVM libraries (default).<br> backend Either a native backend or the C backend.<br> engine Either a native JIT or a bytecode interpreter.<br>__EOD__<br> exit(1);
<br>}</p>
<p># Use -lfoo instead of libfoo.a whenever possible, and add directories to<br># files which can't be found using -L.<br>sub fix_library_names (@) {<br> my @libs = @_;<br> my @result;<br> foreach my $lib (@libs) {
<br> # Transform the bare library name appropriately.<br> my ($basename) = ($lib =~ /^lib([^.]*)\.a/);<br> if (defined $basename) {<br> push @result, "-l$basename";<br> } else {
<br> push @result, "$LIBDIR/$lib";<br> }<br> }<br> return @result;<br>}</p>
<p># Turn the list of libraries into a list of files.<br>sub fix_library_files(@) {<br> my @libs = @_;<br> my @result;<br> foreach my $lib (@libs) {<br> # Transform the bare library name into a filename.<br>
push @result, "$LIBDIR/$lib";<br> }<br> return @result;<br>}</p>
<p>#==========================================================================<br># Library Dependency Analysis<br>#==========================================================================<br># Given a few human-readable library names, find all their dependencies
<br># and sort them into an order which the linker will like. If we packed<br># our libraries into fewer archives, we could make the linker do much<br># of this work for us.<br>#<br># Libraries have two different types of names in this code: Human-friendly
<br># "component" names entered on the command-line, and the raw file names<br># we use internally (and ultimately pass to the linker).<br>#<br># To understand this code, you'll need a working knowledge of Perl 5,
<br># and possibly some quality time with 'man perlref'.</p>
<p>sub load_dependencies;<br>sub build_name_map;<br>sub have_native_backend;<br>sub find_best_engine;<br>sub expand_names (@);<br>sub find_all_required_sets (@);<br>sub find_all_required_sets_helper ($$@);</p>
<p># Each "set" contains one or more libraries which must be included as a<br># group (due to cyclic dependencies). Sets are represented as a Perl array<br># reference pointing to a list of internal library names.
<br>my @SETS;</p>
<p># Various mapping tables.<br>my %LIB_TO_SET_MAP; # Maps internal library names to their sets.<br>my %SET_DEPS; # Maps sets to a list of libraries they depend on.<br>my %NAME_MAP; # Maps human-entered names to internal names.
</p>
<p># Have our dependencies been loaded yet?<br>my $DEPENDENCIES_LOADED = 0;</p>
<p># Given a list of human-friendly component names, translate them into a<br># complete set of linker arguments.<br>sub expand_dependecies (@) {<br> my @libs = @_;<br> load_dependencies;<br> my @required_sets = find_all_required_sets(expand_names(@libs));
<br> my @sorted_sets = topologically_sort_sets(@required_sets);</p>
<p> # Expand the library sets into libraries.<br> my @result;<br> foreach my $set (@sorted_sets) { push @result, @{$set}; }<br> return @result;<br>}</p>
<p># Load in the raw dependency data stored at the end of this file.<br>sub load_dependencies {<br> return if $DEPENDENCIES_LOADED;<br> $DEPENDENCIES_LOADED = 1;<br> while (<DATA>) {<br> # Parse our line.
<br> my ($libs, $deps) = /^(^[^:]+): ?(.*)$/;<br> die "Malformed dependency data" unless defined $deps;<br> my @libs = split(' ', $libs);<br> my @deps = split(' ', $deps);</p>
<p> # Record our dependency data.<br> my $set = \@libs;<br> push @SETS, $set;<br> foreach my $lib (@libs) { $LIB_TO_SET_MAP{$lib} = $set; }<br> $SET_DEPS{$set} = \@deps;<br> }<br> build_name_map;
<br>}</p>
<p># Build a map converting human-friendly component names into internal<br># library names.<br>sub build_name_map {<br> # Add entries for all the actual libraries.<br> foreach my $set (@SETS) {<br> foreach my $lib (sort @$set) {
<br> my $short_name = $lib;<br> $short_name =~ s/^(lib)?LLVM([^.]*)\..*$/$2/;<br> $short_name =~ tr/A-Z/a-z/;<br> $NAME_MAP{$short_name} = [$lib];<br> }<br> }</p>
<p> # Add virtual entries.<br> $NAME_MAP{'native'} = have_native_backend() ? [$ARCH] : [];<br> $NAME_MAP{'backend'} = have_native_backend() ? ['native'] : ['cbackend'];<br> $NAME_MAP{'engine'} = find_best_engine;
<br> $NAME_MAP{'all'} = [name_map_entries]; # Must be last.<br>}</p>
<p># Return true if we have a native backend to use.<br>sub have_native_backend {<br> my %BUILT;<br> foreach my $target (@TARGETS_BUILT) { $BUILT{$target} = 1; }<br> return defined $NAME_MAP{$ARCH} && defined $BUILT{$ARCH};
<br>}</p>
<p># Find a working subclass of ExecutionEngine for this platform.<br>sub find_best_engine {<br> if (have_native_backend && $TARGET_HAS_JIT) {<br> return ['jit', 'native'];<br> } else {<br> return ['interpreter'];
<br> }<br>}</p>
<p># Get all the human-friendly component names.<br>sub name_map_entries {<br> load_dependencies;<br> return sort keys %NAME_MAP;<br>}</p>
<p># Map human-readable names to internal library names.<br>sub expand_names (@) {<br> my @names = @_;<br> my @result;<br> foreach my $name (@names) {<br> if (defined $LIB_TO_SET_MAP{$name}) {<br> # We've hit bottom: An actual library name.
<br> push @result, $name;<br> } elsif (defined $NAME_MAP{$name}) {<br> # We've found a short name to expand.<br> push @result, expand_names(@{$NAME_MAP{$name}});<br> } else {
<br> print STDERR "llvm-config: unknown component name: $name\n";<br> exit(1);<br> }<br> }<br> return @result;<br>}</p>
<p># Given a list of internal library names, return all sets of libraries which<br># will need to be included by the linker (in no particular order).<br>sub find_all_required_sets (@) {<br> my @libs = @_;<br> my %sets_added;
<br> my @result;<br> find_all_required_sets_helper(\%sets_added, \@result, @libs);<br> return @result;<br>}</p>
<p># Recursive closures are pretty broken in Perl, so we're going to separate<br># this function from find_all_required_sets and pass in the state we need<br># manually, as references. Yes, this is fairly unpleasant.<br>
sub find_all_required_sets_helper ($$@) {<br> my ($sets_added, $result, @libs) = @_;<br> foreach my $lib (@libs) {<br> my $set = $LIB_TO_SET_MAP{$lib};<br> next if defined $$sets_added{$set};<br> $$sets_added{$set} = 1;
<br> push @$result, $set;<br> find_all_required_sets_helper($sets_added, $result, @{$SET_DEPS{$set}});<br> }<br>}</p>
<p># Print a list of sets, with a label. Used for debugging.<br>sub print_sets ($@) {<br> my ($label, @sets) = @_;<br> my @output;<br> foreach my $set (@sets) { push @output, join(',', @$set); }<br> print "$label: ", join(';', @output), "\n";
<br>}</p>
<p># Returns true if $lib is a key in $added.<br>sub has_lib_been_added ($$) {<br> my ($added, $lib) = @_;<br> return defined $$added{$LIB_TO_SET_MAP{$lib}};<br>}</p>
<p># Returns true if all the dependencies of $set appear in $added.<br>sub have_all_deps_been_added ($$) {<br> my ($added, $set) = @_;<br> #print_sets(" Checking", $set);<br> #print_sets(" Wants", $SET_DEPS{$set});
<br> foreach my $lib (@{$SET_DEPS{$set}}) {<br> return 0 unless has_lib_been_added($added, $lib);<br> }<br> return 1;<br>}</p>
<p># Given a list of sets, topologically sort them using dependencies.<br>sub topologically_sort_sets (@) {<br> my @sets = @_;<br> my %added;<br> my @result;<br> SCAN: while (@sets) { # We'll delete items from @sets as we go.
<br> #print_sets("So far", reverse(@result));<br> #print_sets("Remaining", @sets);<br> for (my $i = 0; $i < @sets; ++$i) {<br> my $set = $sets[$i];<br> if (have_all_deps_been_added(\%added, $set)) {
<br> push @result, $set;<br> $added{$set} = 1;<br> #print "Removing $i.\n";<br> splice(@sets, $i, 1);<br> next SCAN; # Restart our scan.
<br> }<br> }<br> die "Can't find a library with no dependencies";<br> }<br> return reverse(@result);<br>}</p>
<p># Our library dependency data will be added after the '__END__' token, and will<br># be read through the magic <DATA> filehandle.<br>__END__<br>LLVMARM.o: libLLVMCodeGen.a libLLVMCore.a libLLVMScalarOpts.a libLLVMSelectionDAG.a
libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMipo.a</p>
<p>LLVMAlpha.o: LLVMX86.o libLLVMCodeGen.a libLLVMCore.a libLLVMLinker.a libLLVMScalarOpts.a libLLVMSelectionDAG.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMipo.a</p>
<p>LLVMCBackend.o: libLLVMAnalysis.a libLLVMCodeGen.a libLLVMCore.a libLLVMScalarOpts.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMipa.a</p>
<p>LLVMDataStructure.o: libLLVMAnalysis.a libLLVMBCReader.a libLLVMBCWriter.a libLLVMCore.a libLLVMInstrumentation.a libLLVMScalarOpts.a libLLVMSelectionDAG.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMTransformUtils.a
libLLVMTransforms.a libLLVMipa.a libLLVMipo.a</p>
<p>LLVMExecutionEngine.o: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a</p>
<p>LLVMIA64.o: LLVMX86.o libLLVMCodeGen.a libLLVMCore.a libLLVMScalarOpts.a libLLVMSelectionDAG.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMipo.a</p>
<p>LLVMInterpreter.o: LLVMExecutionEngine.o LLVMJIT.o libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMipo.a</p>
<p>LLVMJIT.o: LLVMExecutionEngine.o libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMipo.a</p>
<p>LLVMPowerPC.o: LLVMX86.o libLLVMCodeGen.a libLLVMCore.a libLLVMLinker.a libLLVMScalarOpts.a libLLVMSelectionDAG.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMTransformUtils.a libLLVMipo.a</p>
<p>LLVMSparc.o: LLVMX86.o libLLVMCodeGen.a libLLVMCore.a libLLVMScalarOpts.a libLLVMSelectionDAG.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMipo.a</p>
<p>LLVMX86.o: libLLVMCodeGen.a libLLVMCore.a libLLVMLinker.a libLLVMScalarOpts.a libLLVMSelectionDAG.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMTransformUtils.a libLLVMipa.a libLLVMipo.a</p>
<p>libLLVMAnalysis.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a</p>
<p>libLLVMArchive.a: libLLVMBCReader.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a</p>
<p>libLLVMAsmParser.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a</p>
<p>libLLVMBCReader.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a</p>
<p>libLLVMBCWriter.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a</p>
<p>libLLVMCodeGen.a: libLLVMAnalysis.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a</p>
<p>libLLVMCore.a: libLLVMSupport.a libLLVMSystem.a</p>
<p>libLLVMDebugger.a: libLLVMBCReader.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a</p>
<p>libLLVMInstrumentation.a: libLLVMCore.a libLLVMScalarOpts.a libLLVMSupport.a libLLVMTransformUtils.a</p>
<p>libLLVMLinker.a: libLLVMArchive.a libLLVMBCReader.a libLLVMCore.a libLLVMSystem.a</p>
<p>libLLVMScalarOpts.a: libLLVMAnalysis.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMTransformUtils.a</p>
<p>libLLVMSelectionDAG.a libLLVMTarget.a libLLVMSelectionDAG.a libLLVMTarget.a: libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMSystem.a<br> libLLVMTransformUtils.a</p>
<p>libLLVMSupport.a: libLLVMSystem.a libLLVMbzip2.a</p>
<p>libLLVMSystem.a: </p>
<p>libLLVMTransformUtils.a: libLLVMAnalysis.a libLLVMCore.a libLLVMScalarOpts.a libLLVMSupport.a libLLVMSystem.a libLLVMipa.a</p>
<p>libLLVMTransforms.a: libLLVMCore.a libLLVMSupport.a libLLVMTarget.a libLLVMTransformUtils.a</p>
<p>libLLVMbzip2.a: </p>
<p>libLLVMipa.a: libLLVMAnalysis.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a</p>
<p>libLLVMipo.a: libLLVMAnalysis.a libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMTransformUtils.a libLLVMipa.a</p></div>