# New Ticket Created by  Andy Dougherty 
# Please include the string:  [perl #17007]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=17007 >


On Wed, 9 Jan 2002, Andy Dougherty wrote:

> > >For perl5, the main makefile calls (essentially)
> > >
> > >         $(CC) -o perl
> > >
> > >while the parrot Makefile calls
> > >
> > >         $(LD) -o test_main

> On Wed, 9 Jan 2002, Dan Sugalski wrote:
> > 
> > It's a platform-independence issue. Non-Unix platforms need to call the 
> > linker, unix ones don't.

[Me again, still from January:]
> I think we've got lots of things mixed up on all ends.  Perl5's
> Unix-centric Configure is showing up again.
> 
> Specifically, Perl5's $Config{ld} is documented as follows:
> 
> ld:     This variable indicates the program to be used to link
>         libraries for dynamic loading.  On some systems, it is 'ld'.
>         On ELF systems, it should be $cc.  Mostly, we'll try to respect
>         the hint file setting.
> 
> The problem is that we really need at least *three* variables, something
> like the following:
> 
> Variable      description
> cc            Compiler -- used to turn .c files into object files.
>               (Usually cc or cl, or something like that.)
> link          Linker, used to link object files (plus libraries) into
>               an executable.  Usually $cc on Unix-ish systems.  VMS and
>               Win32 might use "Link". 
> ld            Tool used to build dynamically loadable libraries.  Often
>               $cc on Unix-ish systems, but apparently sometimes it's ld.

> Perl5's Configure/Makefile.SH build system incorrectly _assumes_ that 
> linker=$cc.

> One possible "fix" for now is to introduce these *three* variables into
> parrot's Configure, and letting ${link} default to ${cc} for now,
> unless overridden by a hints file.  The parrot Makefile would then call
> (essentially)
>       $(LINK) -o test_main
> and HP/UX would work again.

Here, at long last, is a patch to implement that "fix".  I'd appreciate
folks testing it on HP/UX and on non-Unix platforms.

I'm not particularly wedded to the names qw(cc link ld).  Any reasonable
set will do.

If this patch is accepted, some hints files which set ldflags may need
revisiting -- it's not clear to me if they were being set for passing
to $link or $ld.

diff -r -u parrot-orig/config/gen/makefiles/root.in 
parrot-andy/config/gen/makefiles/root.in
--- parrot-orig/config/gen/makefiles/root.in    Wed Sep  4 09:00:38 2002
+++ parrot-andy/config/gen/makefiles/root.in    Wed Sep  4 15:46:23 2002
@@ -5,6 +5,7 @@
 RM_RF = ${rm_rf}
 AR_CR = ${ar} cr
 RANLIB = ${ranlib}
+LINK = ${link}
 LD = ${ld}
 LD_SHARED = ${ld_shared}
 LD_OUT = ${ld_out}
@@ -116,6 +117,7 @@
 ###############################################################################
 
 CFLAGS = ${ccflags} ${cc_warn} ${cc_inc} ${cc_hasjit} ${cg_flag}
+LINKFLAGS = ${linkflags}
 LDFLAGS = ${ldflags}
 
 C_LIBS = ${libs}
@@ -161,7 +163,7 @@
 mops : examples/assembly/mops${exe} examples/mops/mops${exe}
 
 $(TEST_PROG) : test_main$(O) $(GEN_HEADERS) $(O_DIRS) $(O_FILES) 
lib/Parrot/OpLib/core.pm lib/Parrot/PMC.pm
-       $(LD) ${ld_out}$(TEST_PROG) $(LDFLAGS) $(O_FILES) test_main$(O) $(C_LIBS)
+       $(LINK) ${ld_out}$(TEST_PROG) $(LINKFLAGS) $(O_FILES) test_main$(O) $(C_LIBS)
 
 lib_deps_object : $(O_DIRS) $(O_FILES)
        $(PERL) tools/dev/lib_deps.pl object $(O_FILES)
@@ -197,7 +199,7 @@
        $(LD) $(LD_SHARED) $(LD_SHARED_FLAGS) $(LDFLAGS) 
$(LD_OUT)blib/lib/libparrot$(SO) $(O_FILES) $(C_LIBS)
 
 $(TEST_PROG_SO) : test_main$(O) blib/lib/libparrot$(SO) lib/Parrot/OpLib/core.pm 
lib/Parrot/PMC.pm
-       $(LD) $(LDFLAGS) $(LD_OUT)$(TEST_PROG) test_main$(O) blib/lib/libparrot$(A) 
$(C_LIBS)
+       $(LINK) $(LINKFLAGS) $(LD_OUT)$(TEST_PROG) test_main$(O) 
+blib/lib/libparrot$(A) $(C_LIBS)
 
 # XXX The dependancies on SO.MAJOR.MINOR and SO.VERSION are removed 
 #     because those should be done at "make install" and not "make shared"
@@ -242,7 +244,7 @@
 pdb$(O) : $(GENERAL_H_FILES)
 
 $(PDB) : pdb$(O) $(O_DIRS) $(O_FILES)
-       $(LD) ${ld_out}$(PDB) pdb$(O) $(O_FILES) $(C_LIBS) $(LDFLAGS)
+       $(LINK) ${ld_out}$(PDB) pdb$(O) $(LINKFLAGS) $(O_FILES) $(C_LIBS)
 
 #
 # Parrot Disassembler
@@ -252,14 +254,14 @@
 disassemble$(O) : $(GENERAL_H_FILES)
 
 $(DIS) : disassemble$(O) $(O_DIRS) $(O_FILES)
-       $(LD) ${ld_out}$(DIS) disassemble$(O) $(O_FILES) $(C_LIBS) $(LDFLAGS)
+       $(LINK) ${ld_out}$(DIS) disassemble$(O) $(LINKFLAGS) $(O_FILES) $(C_LIBS)
 
 #
 # Parrot Dump
 #
 
 #$(PDUMP) : pdump$(O) packfile$(O)
-#      $(LD) ${ld_out}$(PDUMP) pdump$(O) packfile$(O) string$(O) chartype$(O) 
memory$(O) $(C_LIBS) $(LDFLAGS)
+#      $(LINK) ${ld_out}$(PDUMP) $(LINKFLAGS) pdump$(O) packfile$(O) string$(O) 
+chartype$(O) memory$(O) $(C_LIBS)
 
 
 ###############################################################################
@@ -289,7 +291,7 @@
        $(PERL) pbc2c.pl examples/assembly/mops.pbc > examples/assembly/mops.c
 
 examples/assembly/mops${exe} : examples/assembly/mops$(O) $(O_DIRS) $(O_FILES)
-       $(LD) $(LDFLAGS) ${ld_out}examples/assembly/mops${exe} 
examples/assembly/mops$(O) $(O_FILES) $(C_LIBS)
+       $(LINK) $(LINKFLAGS) ${ld_out}examples/assembly/mops${exe} 
+examples/assembly/mops$(O) $(O_FILES) $(C_LIBS)
 
 examples/assembly/life.pbc : examples/assembly/life.pasm assemble.pl
        cd examples && cd assembly && $(MAKE) life.pbc PERL=$(PERL) && cd .. && cd ..
@@ -298,7 +300,7 @@
        $(PERL) pbc2c.pl examples/assembly/life.pbc > examples/assembly/life.c
 
 examples/assembly/life${exe} : examples/assembly/life$(O) $(O_DIRS) $(O_FILES)
-       $(LD) $(LDFLAGS) ${ld_out}examples/assembly/life${exe} 
examples/assembly/life$(O) $(O_FILES) $(C_LIBS)
+       $(LINK) $(LINKFLAGS) ${ld_out}examples/assembly/life${exe} 
+examples/assembly/life$(O) $(O_FILES) $(C_LIBS)
 
 ###############################################################################
 #
@@ -309,7 +311,7 @@
 examples/mops/mops$(O) : examples/mops/mops.c
 
 examples/mops/mops${exe} : examples/mops/mops$(O) platform$(O)
-       $(LD) $(LDFLAGS) ${ld_out}examples/mops/mops${exe} examples/mops/mops$(O) 
platform$(O) $(C_LIBS)
+       $(LINK) $(LINKFLAGS) ${ld_out}examples/mops/mops${exe} examples/mops/mops$(O) 
+platform$(O) $(C_LIBS)
 
 
 ###############################################################################
diff -r -u parrot-orig/config/init/data.pl parrot-andy/config/init/data.pl
--- parrot-orig/config/init/data.pl     Thu Aug 29 16:56:29 2002
+++ parrot-andy/config/init/data.pl     Wed Sep  4 15:05:03 2002
@@ -14,12 +14,27 @@
   package Configure::Data;
   use Config;
   use Data::Dumper;
+
+  # We need a Glossary somewhere!
   
   my(%c)=(
     debugging     => $debugging ? 1 : 0,
 
+    # Compiler -- used to turn .c files into object files.
+    # (Usually cc or cl, or something like that.)
     cc            => $Config{cc},
     ccflags       => $Config{ccflags},
+
+    # Linker, used to link object files (plus libraries) into
+    # an executable.  It is usually $cc on Unix-ish systems.
+    # VMS and Win32 might use "Link". 
+    # Perl5's Configure doesn't distinguish linking from loading, so
+    # make a reasonable guess at defaults.
+    link          => $Config{cc},
+    linkflags     => $Config{ldflags},
+
+    # ld:  Tool used to build dynamically loadable libraries.  Often
+    # $cc on Unix-ish systems, but apparently sometimes it's ld.
     ld            => $Config{ld},
     ldflags       => $Config{ldflags},
     
@@ -27,6 +42,7 @@
     
     cc_inc       => "-I./include",
     cc_debug      => '-g',
+    link_debug    => '',
     cc_warn       => '',
     o             => '.o',                # object files extension
     so            => '.so',               # dynamic link library or shared object 
extension
diff -r -u parrot-orig/config/init/debug.pl parrot-andy/config/init/debug.pl
--- parrot-orig/config/init/debug.pl    Thu Aug 22 17:55:41 2002
+++ parrot-andy/config/init/debug.pl    Wed Sep  4 15:03:36 2002
@@ -12,13 +12,17 @@
   if (! Configure::Data->get('debugging')) {
     print "(none requested) ";
   }
-  my($ccflags, $ldflags)=Configure::Data->get(qw(ccflags ldflags));
-  my($cc_debug, $ld_debug)=Configure::Data->get(qw(cc_debug ld_debug));
+  my($ccflags, $linkflags, $ldflags) = 
+      Configure::Data->get(qw(ccflags linkflags ldflags));
+  my($cc_debug, $link_debug, $ld_debug) = 
+      Configure::Data->get(qw(cc_debug link_debug ld_debug));
   $ccflags .= " $cc_debug";
+  $linkflags .= " $link_debug";
   $ldflags .= " $ld_debug";
 
   Configure::Data->set(
                        ccflags => $ccflags,
+                       linkflags => $linkflags,
                        ldflags => $ldflags,
                       );
 }
diff -r -u parrot-orig/config/inter/progs.pl parrot-andy/config/inter/progs.pl
--- parrot-orig/config/inter/progs.pl   Tue Jun  4 21:59:40 2002
+++ parrot-andy/config/inter/progs.pl   Wed Sep  4 15:06:48 2002
@@ -6,14 +6,16 @@
 
 $description = 'Determining what C compiler and linker to use...';
 
-@args = qw(ask cc ld ccflags ldflags libs debugging);
+@args = qw(ask cc link ld ccflags linkflags ldflags libs debugging);
 
 sub runstep {
   my %args;
   @args{@args}=@_;
   
-  my($cc, $ld, $ccflags, $ldflags, $libs)=Configure::Data->get(qw(cc ld ccflags 
ldflags libs));
+  my($cc, $link, $ld, $ccflags, $linkflags, $ldflags, $libs) = 
+      Configure::Data->get(qw(cc link ld ccflags linkflags ldflags libs));
   $ccflags =~ s/-D(PERL|HAVE)_\w+\s*//g;
+  $linkflags =~ s/-libpath:\S+//g;
   $ldflags =~ s/-libpath:\S+//g;
   my $debug='n';
   
@@ -22,8 +24,10 @@
            split(' ', $libs);
   
   $cc=$args{cc}           if defined $args{cc};
+  $link=$args{link}       if defined $args{link};
   $ld=$args{ld}           if defined $args{ld};
   $ccflags=$args{ccflags} if defined $args{ccflags};
+  $linkflags=$args{linkflags} if defined $args{linkflags};
   $ldflags=$args{ldflags} if defined $args{ldflags};
   $libs=$args{libs}       if defined $args{libs};
   $debug=$args{debugging} if defined $args{debugging};
@@ -41,9 +45,12 @@
 END
 
     $cc=prompt("What C compiler do you want to use?", $cc);
-    $ld=prompt("How about your linker?", $ld);
+    $link=prompt("How about your linker?", $link);
+    $ld=prompt("What program do you want to use to build shared libraries?", 
+              $ld);
     $ccflags=prompt("What flags should your C compiler receive?", $ccflags);
-    $ldflags=prompt("And your linker?", $ldflags);
+    $linkflags=prompt("And your linker?", $linkflags);
+    $ldflags=prompt("And your $ld for building shared libraries?", $ldflags);
     $libs=prompt("What libraries should your C compiler use?", $libs);
     $debug=prompt("Do you want a debugging build of Parrot?", $debug);
   }
@@ -57,8 +64,10 @@
   
   Configure::Data->set(
     cc      => $cc,
+    link    => $link,
     ld      => $ld,
     ccflags => $ccflags,
+    linkflags => $linkflags,
     ldflags => $ldflags,
     libs    => $libs
   );
diff -r -u parrot-orig/languages/perl6/perl6 parrot-andy/languages/perl6/perl6
--- parrot-orig/languages/perl6/perl6   Tue Aug 27 12:00:53 2002
+++ parrot-andy/languages/perl6/perl6   Wed Sep  4 15:39:43 2002
@@ -645,7 +645,7 @@
        # in advance
        #
        my $lib = !$o{shared} ? "libparrot$LIB" : '-L blib/lib -lparrot';
-       $cmd = "$CD $PConfig{ld} $PConfig{ldflags} ".
+       $cmd = "$CD $PConfig{link} $PConfig{linkflags} ".
        "$PConfig{ld_out} $HERE/$filebase $HERE/$filebase$PConfig{'o'} ".
        "$lib ".
        "$PConfig{libs}";
diff -r -u parrot-orig/lib/Parrot/Configure/Step.pm 
parrot-andy/lib/Parrot/Configure/Step.pm
--- parrot-orig/lib/Parrot/Configure/Step.pm    Wed Sep  4 16:01:08 2002
+++ parrot-andy/lib/Parrot/Configure/Step.pm    Wed Sep  4 15:41:04 2002
@@ -118,12 +118,12 @@
 }
 
 sub cc_build {
-       my($cc, $ccflags, $ldout, $o, $ld, $ldflags, $cc_exe_out, $exe, $libs)=
-               Configure::Data->get( qw(cc ccflags ld_out o ld ldflags cc_exe_out exe 
libs) );
+       my($cc, $ccflags, $ldout, $o, $link, $linkflags, $cc_exe_out, $exe, $libs)=
+               Configure::Data->get( qw(cc ccflags ld_out o link linkflags cc_exe_out 
+exe libs) );
        
        system("$cc $ccflags -I./include -c test.c >test.cco $redir_err") and die "C 
compiler failed (see test.cco)";
        
-       system("$ld $ldflags test$o ${cc_exe_out}test$exe $libs >test.ldo $redir_err") 
and die "Linker failed (see test.ldo)";
+       system("$link $linkflags test$o ${cc_exe_out}test$exe $libs >test.ldo 
+$redir_err") and die "Linker failed (see test.ldo)";
 }
 
 sub cc_run {
diff -r -u parrot-orig/lib/Parrot/Test.pm parrot-andy/lib/Parrot/Test.pm
--- parrot-orig/lib/Parrot/Test.pm      Wed Aug 28 01:10:54 2002
+++ parrot-andy/lib/Parrot/Test.pm      Wed Sep  4 15:41:53 2002
@@ -165,7 +165,7 @@
       close SOURCE;
 
       _run_command("$PConfig{cc} $PConfig{ccflags} -I./include -c 
$PConfig{ld_out}$obj_f $source_f");
-      _run_command("$PConfig{ld} $PConfig{ldflags} $obj_f $PConfig{cc_exe_out}$exe_f 
$PConfig{libs} blib/lib/libparrot$PConfig{a}");
+      _run_command("$PConfig{link} $PConfig{linkflags} $obj_f 
+$PConfig{cc_exe_out}$exe_f $PConfig{libs} blib/lib/libparrot$PConfig{a}");
       my $prog_output;
       _run_command(".$PConfig{slash}$exe_f", 'STDOUT' => $out_f, 'STDERR' => $out_f);
 
-- 
    Andy Dougherty              [EMAIL PROTECTED]
    Dept. of Physics
    Lafayette College, Easton PA 18042



Reply via email to