[llvm-commits] Problem with GenLibDeps.pl and MinGW (32-bit)

David Waggoner mathonnapkins at gmail.com
Mon Jan 16 21:22:43 PST 2012

Dear All,

Over the past months I've had quite a bit of trouble building llvm 2.9 and
3.0 using MinGW+MSYS+Perl 5.6.1 for MSYS on a Windows XP SP 3 computer. I
should also specify that I was consistently not using "--enable-shared" in
the configure script when I saw this issue. I was using
"--enable-optimized" and "--disable-assertions". How much of that is
relevant to this particular problem, I don't really know. There were plenty
of problems that turned out to be my own fault, but eventually I hit a snag
that I couldn't attribute to myself. llvm-config was failing to produce
dependencies list for all of the core libraries (e.g. llvm/Release/lib). At
first I didn't know much of how to address this issue, but I finally these
past few days tracked the issue to /llvm/utils/GenLibDeps.pl. Essentially,
my environment differed enough from my other computer (Linux) to the point
where the "chomp" command in the while(<UNDEFS>) loops in gen_one_entry()
was apparently not stripping CR characters ('\r' or '\x0D') from the key
that was to be tested ($_). So, for example:

# Earlier in the script, associating symbols with the library they are
defined in.
$libdefs{"llvm_foo_symbol"} = "llvm_foo_library.a";

# Later on, trying to generate dependency lists, but it's destined to fail,
b/c "chomp" isn't doing enough chomping.
if(defined $libdefs{"llvm_foo_symbol\r"} ... ) { ... }

For the record, I have built llvm using a Linux distro with far fewer
hiccups. And I seem to recall that building llvm with this same MinGW
environment but using --enable-shared worked somewhat, but I can't recall
if I had to do some makefile hacking to make that work as well. The only
reason I mention it is that I think I saw llvm-config as an *.exe once,
rather than as a shell script. Let me know if I'm talking craziness.

I am not at all a frequent Perl coder, so please review this patch with an
extra hint of caution.

~MathOnNapkins (Dave)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120117/9d28ac80/attachment.html>
-------------- next part --------------
Index: utils/GenLibDeps.pl
--- utils/GenLibDeps.pl	(revision 148282)
+++ utils/GenLibDeps.pl	(working copy)
@@ -208,7 +208,8 @@
     "$nmPath -u $Directory/$lib | sed -e 's/^[ 0]* U //' | sort | uniq |";
   my %DepLibs;
   while (<UNDEFS>) {
-    chomp;
+    s/\015?\012?//; # not sure if <UNDEFS> is in binmode or uses LF or CRLF
+                    # this strips both LF and CRLF
     my $lib_printed = 0;
     if (defined($libdefs{$_}) && $libdefs{$_} ne $lib) {
       $DepLibs{$libdefs{$_}} = [] unless exists $DepLibs{$libdefs{$_}};

More information about the llvm-commits mailing list