[llvm-commits] [llvm] r58687 - /llvm/trunk/tools/llvm-config/llvm-config.in.in

Julien Lerouge jlerouge at apple.com
Tue Nov 4 11:58:18 PST 2008


On Tue, Nov 04, 2008 at 08:05:21AM +0000, Nick Lewycky wrote:
> Author: nicholas
> Date: Tue Nov  4 02:05:21 2008
> New Revision: 58687
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=58687&view=rev
> Log:
> Don't "shell out" to resolve paths. Using pure perl makes llvm-config
> friendlier to non-Unixes that happen to have perl. Patch from Sascha Othman!
> 
> Modified:
>     llvm/trunk/tools/llvm-config/llvm-config.in.in
> 
> Modified: llvm/trunk/tools/llvm-config/llvm-config.in.in
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/llvm-config.in.in?rev=58687&r1=58686&r2=58687&view=diff
> 

Hello Nick,

This breaks LLVM build on MingW. Seems like realpath is not really
working as expected on that platform (Using perl 5.6.1, I get errors
like: readdir(/c/llvm-build/Release/bin/../../../..): Bad file number at
/c/llvm-build/Release//bin/llvm-config line 74).

Can we revert to using the shell and pwd, or use File::Spec instead ?
The patch below works for me on MingW and MacOS, but it might break some
other platforms.

File::Spec handles things slightly differently, as noted on the CPAN
doc:

| Note that this does *not* collapse x/../y sections into y. This is by
| design. If /foo on your system is a symlink to /bar/baz, then
| /foo/../quux is actually /bar/quux, not /quux as a naive ../-removal
| would give you. If you want to do this kind of processing, you probably
| want Cwd's realpath() function to actually traverse the filesystem
| cleaning up paths like this.

Thanks,
Julien

-- 
Julien Lerouge
PGP Key Id: 0xB1964A62
PGP Fingerprint: 392D 4BAD DB8B CE7F 4E5F FA3C 62DB 4AA7 B196 4A62
PGP Public Key from: keyserver.pgp.com
-------------- next part --------------
Index: tools/llvm-config/llvm-config.in.in
===================================================================
--- tools/llvm-config/llvm-config.in.in	(revision 58710)
+++ tools/llvm-config/llvm-config.in.in	(working copy)
@@ -18,7 +18,7 @@
 use 5.006;
 use strict;
 use warnings;
-use Cwd;
+use File::Spec;
 
 #---- begin autoconf values ----
 my $PACKAGE_NAME        = q{@PACKAGE_NAME@};
@@ -67,11 +67,11 @@
 
 # Turn the directory into an absolute directory on the file system, also pop up
 # from "bin" into the build or prefix dir.
-my $ABS_RUN_DIR = Cwd::realpath("$RUN_DIR/..");
+my $ABS_RUN_DIR = File::Spec->rel2abs("$RUN_DIR/..");
 
 # Compute the absolute object directory build, e.g. "foo/llvm/Debug".
 my $ABS_OBJ_ROOT = "$LLVM_OBJ_ROOT/$LLVM_BUILDMODE";
-$ABS_OBJ_ROOT = Cwd::realpath($ABS_OBJ_ROOT) if (-d $ABS_OBJ_ROOT);
+$ABS_OBJ_ROOT = File::Spec->rel2abs("$ABS_OBJ_ROOT") if (-d $ABS_OBJ_ROOT);
 
 my $INCLUDEDIR = "$ABS_RUN_DIR/include";
 my $LIBDIR     = "$ABS_RUN_DIR/lib";
@@ -135,9 +135,9 @@
         } elsif ($arg eq "--build-mode") {
             $has_opt = 1; print "$LLVM_BUILDMODE\n";
         } elsif ($arg eq "--obj-root") {
-            $has_opt = 1; print Cwd::realpath($LLVM_OBJ_ROOT), "\n";
+            $has_opt = 1; print File::Spec->rel2abs($LLVM_OBJ_ROOT), "\n";
         } elsif ($arg eq "--src-root") {
-            $has_opt = 1; print Cwd::realpath($LLVM_SRC_ROOT), "\n";
+            $has_opt = 1; print File::Spec->rel2abs($LLVM_SRC_ROOT), "\n";
         } else {
             usage();
         }


More information about the llvm-commits mailing list