# New Ticket Created by Andy Dougherty
# Please include the string: [perl #18319]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=18319 >
I've gotten no negative feedback (no positive either, but that's normal)
so I propose that the following patch go in.
On Tue, 29 Oct 2002, Andy Dougherty wrote:
> On Tue, 29 Oct 2002, Andy Dougherty wrote:
>
> > Here's my proposal for stage one: This patch is intended to define
> > explicitly what the different compiler and linker commands and flags
> > are, what they are supposed to mean, and how they are to be used.
I've gotten a little feedback. Here's my proposed patch. I added yet
more documentation and cleaned up config/gen/makefiles/root.in to use the
variables consistently. Also, with the new link_out variable, the stack
direction test should work again with MS Visual C. It might even work
with VMS, though lots of other things still won't. I had to make some
guesses for all those systems.
I did not fix up Makefiles in different sub-directories or any other build
commands that are part of the test suite. Nor did I generalize the
stackdir.pl stuff to a generic Configure function. One thing at a time.
diff -r -u parrot-orig/config/auto/stackdir.pl parrot-andy/config/auto/stackdir.pl
--- parrot-orig/config/auto/stackdir.pl Mon Oct 21 09:44:36 2002
+++ parrot-andy/config/auto/stackdir.pl Thu Oct 31 11:57:03 2002
@@ -18,19 +18,33 @@
genfile('config/auto/stackdir/test1_c.in', 'test1.c');
genfile('config/auto/stackdir/test2_c.in', 'test2.c');
- 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) );
+ my($cc, $ccflags, $cc_c, $cc_inc, $o, $link, $linkflags,
+ $link_out, $exe, $libs) =
+ Configure::Data->get( qw(cc ccflags cc_c cc_inc o link linkflags
+ link_out exe libs) );
- system("$cc $ccflags -I./include -c test0.c >test0.cco $redir_err") and
- die "C compiler failed (see test0.cco)";
- system("$cc $ccflags -I./include -c test1.c >test1.cco $redir_err") and
- die "C compiler failed (see test1.cco)";
- system("$cc $ccflags -I./include -c test2.c >test2.cco $redir_err") and
- die "C compiler failed (see test2.cco)";
- system("$link $linkflags ${cc_exe_out}test$exe test0$o test1$o test2$o $libs
>test.ldo $redir_err") and
- die "Linker failed (see test.ldo)";
+ # XXX VMS syntax is only a guess!
+ # (The main issue is what to do about redirecting errors.)
+ if ($^O =~ /VMS/) {
+ system("$cc $ccflags $cc_inc $cc_c test0.c") and
+ die "C compiler failed for test0.c.";
+ system("$cc $ccflags $cc_inc $cc_c test1.c") and
+ die "C compiler failed for test1.c.";
+ system("$cc $ccflags $cc_inc $cc_c test2.c") and
+ die "C compiler failed for test2.c.";
+ system("$link $linkflags ${link_out}test$exe test0$o,test1$o,test2$o $libs")
+and
+ die "Linker failed for stack direction test.";
+ }
+ else {
+ system("$cc $ccflags $cc_inc $cc_c test0.c >test0.cco $redir_err") and
+ die "C compiler failed (see test0.cco)";
+ system("$cc $ccflags $cc_inc $cc_c test1.c >test1.cco $redir_err") and
+ die "C compiler failed (see test1.cco)";
+ system("$cc $ccflags $cc_inc $cc_c test2.c >test2.cco $redir_err") and
+ die "C compiler failed (see test2.cco)";
+ system("$link $linkflags ${link_out}test$exe test0$o test1$o test2$o $libs
+>test.ldo $redir_err") and
+ die "Linker failed (see test.ldo)";
+ }
my %results=eval cc_run();
cc_clean();
diff -r -u parrot-orig/config/gen/makefiles/root.in
parrot-andy/config/gen/makefiles/root.in
--- parrot-orig/config/gen/makefiles/root.in Mon Oct 28 12:25:36 2002
+++ parrot-andy/config/gen/makefiles/root.in Thu Oct 31 10:00:21 2002
@@ -7,8 +7,9 @@
RANLIB = ${ranlib}
LINK = ${link}
LD = ${ld}
+# link_out and ld_out might have trailing spaces, so they are handled
+# by the input file, config/gen/makefiles/root.in.
LD_SHARED = ${ld_shared}
-LD_OUT = ${ld_out}
LD_SHARED_FLAGS=${ld_shared_flags}
INC=include/parrot
@@ -168,7 +169,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
- $(LINK) ${ld_out}$(TEST_PROG) $(LINKFLAGS) $(O_FILES) test_main$(O) $(C_LIBS)
+ $(LINK) ${link_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)
@@ -201,17 +202,17 @@
$(RANLIB) $@
blib/lib/libparrot$(SO) : blib/lib $(O_DIRS) $(O_FILES)
- $(LD) $(LD_SHARED) $(LD_SHARED_FLAGS) $(LDFLAGS)
$(LD_OUT)blib/lib/libparrot$(SO) $(O_FILES) $(C_LIBS)
+ $(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
- $(LINK) $(LINKFLAGS) $(LD_OUT)$(TEST_PROG) test_main$(O)
blib/lib/libparrot$(A) $(C_LIBS)
+ $(LINK) $(LINKFLAGS) ${link_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"
# It also makes the task of getting this working on win32 much easier. :)
#
#blib/lib/libparrot$(SO).${VERSION} : blib/lib $(O_DIRS) $(O_FILES)
-# $(LD) $(LD_SHARED) -Wl,-soname,libparrot$(SO).${MAJOR} $(LDFLAGS)
$(LD_OUT)blib/lib/libparrot$(SO).${VERSION} $(O_FILES)
+# $(LD) $(LD_SHARED) -Wl,-soname,libparrot$(SO).${MAJOR} $(LDFLAGS)
+${ld_out}blib/lib/libparrot$(SO).${VERSION} $(O_FILES)
#
#blib/lib/libparrot$(SO).${MAJOR}.${MINOR} : blib/lib/libparrot$(SO).${VERSION}
# $(RM_F) $@
@@ -226,7 +227,7 @@
# cd blib/lib; ln -s libparrot$(SO).${MAJOR} libparrot$(SO)
#
#blib/lib/libcore_prederef$(SO).${VERSION} : blib/lib core_ops_prederef$(O)
-# $(LD) $(LD_SHARED) -Wl,-soname,libparrot$(SO).${MAJOR} $(LDFLAGS)
$(LD_OUT)blib/lib/libcore_prederef$(SO).${VERSION} core_ops_prederef$(O)
+# $(LD) $(LD_SHARED) -Wl,-soname,libparrot$(SO).${MAJOR} $(LDFLAGS)
+${ld_out}blib/lib/libcore_prederef$(SO).${VERSION} core_ops_prederef$(O)
#
#blib/lib/libcore_prederef$(SO).${MAJOR}.${MINOR} :
blib/lib/libcore_prederef$(SO).${VERSION}
# $(RM_F) $@
@@ -249,7 +250,7 @@
pdb$(O) : $(GENERAL_H_FILES)
$(PDB) : pdb$(O) $(O_DIRS) $(O_FILES)
- $(LINK) ${ld_out}$(PDB) pdb$(O) $(LINKFLAGS) $(O_FILES) $(C_LIBS)
+ $(LINK) ${link_out}$(PDB) pdb$(O) $(LINKFLAGS) $(O_FILES) $(C_LIBS)
#
# Parrot Disassembler
@@ -259,14 +260,14 @@
disassemble$(O) : $(GENERAL_H_FILES)
$(DIS) : disassemble$(O) $(O_DIRS) $(O_FILES)
- $(LINK) ${ld_out}$(DIS) disassemble$(O) $(LINKFLAGS) $(O_FILES) $(C_LIBS)
+ $(LINK) ${link_out}$(DIS) disassemble$(O) $(LINKFLAGS) $(O_FILES) $(C_LIBS)
#
# Parrot Dump
#
$(PDUMP) : pdump$(O) packdump$(O) $(O_FILES) $(O_DIRS)
- $(LINK) ${ld_out}$(PDUMP) pdump$(O) packdump$(O) $(LINKFLAGS) $(O_FILES)
$(C_LIBS)
+ $(LINK) ${link_out}$(PDUMP) pdump$(O) packdump$(O) $(LINKFLAGS) $(O_FILES)
+$(C_LIBS)
###############################################################################
@@ -296,7 +297,7 @@
$(PERL) pbc2c.pl examples/assembly/mops.pbc > examples/assembly/mops.c
examples/assembly/mops${exe} : examples/assembly/mops$(O) $(O_DIRS) $(O_FILES)
- $(LINK) $(LINKFLAGS) ${ld_out}examples/assembly/mops${exe}
examples/assembly/mops$(O) $(O_FILES) $(C_LIBS)
+ $(LINK) $(LINKFLAGS) ${link_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 ..
@@ -305,7 +306,7 @@
$(PERL) pbc2c.pl examples/assembly/life.pbc > examples/assembly/life.c
examples/assembly/life${exe} : examples/assembly/life$(O) $(O_DIRS) $(O_FILES)
- $(LINK) $(LINKFLAGS) ${ld_out}examples/assembly/life${exe}
examples/assembly/life$(O) $(O_FILES) $(C_LIBS)
+ $(LINK) $(LINKFLAGS) ${link_out}examples/assembly/life${exe}
+examples/assembly/life$(O) $(O_FILES) $(C_LIBS)
###############################################################################
#
@@ -316,7 +317,7 @@
examples/mops/mops$(O) : examples/mops/mops.c
examples/mops/mops${exe} : examples/mops/mops$(O)
- $(LINK) $(LINKFLAGS) ${ld_out}examples/mops/mops${exe} \
+ $(LINK) $(LINKFLAGS) ${link_out}examples/mops/mops${exe} \
examples/mops/mops$(O) blib/lib/libparrot$(A) $(C_LIBS)
diff -r -u parrot-orig/config/init/data.pl parrot-andy/config/init/data.pl
--- parrot-orig/config/init/data.pl Thu Sep 12 10:39:22 2002
+++ parrot-andy/config/init/data.pl Thu Oct 31 10:14:35 2002
@@ -20,44 +20,76 @@
my(%c)=(
debugging => $debugging ? 1 : 0,
+ # Flags for compiling, linking, and building shared libraries.
+ # Note that for some systems, a space may be required between an
+ # output flag and the target (e.g. cc -o foo), while for
+ # other systems, no space might be allowed
+ # (e.g. link /exe=foo.exe). Therefore, several of the "output"
+ # variables below have trailing spaces. Be careful to keep them.
+
# Compiler -- used to turn .c files into object files.
# (Usually cc or cl, or something like that.)
+ # Compile C source files with
+ # $cc $ccflags $cc_inc $cc_debug $cc_warn $cc_c ${cc_c_out} file$o file.c
+ # If you want this object file to be part of a shared library,
+ # then you need to compile instead with
+ # $cc $ccflags $cc_inc $cc_debug $cc_warn $cc_dlflags $cc_c ${cc_c_out}file$o
+file.c
+ # These Unix-ish defaults should be overridden by hints files
+ # as necessary for Win32, VMS, and other non-Unix systems.
cc => $Config{cc},
ccflags => $Config{ccflags},
+ cc_c => '-c', # Empty for VMS.
+ cc_inc => "-I./include", # How to pick up parrot includes.
+ # XXX Won't work in subdirectories!
+ # We need to use File::Spec.
+ cc_debug => '-g',
+ cc_warn => '',
+ cc_dlflags => $Config{cccdlflags}, # Flags necessary to compile
+ # this file for use in a shared library.
+ cc_o_out => '-o ', # cc object output file. XXX Is this portable?
+ cc_exe_out => '-o ', # cc executable output file. Don't use this.
+ # Use $link to create executables.
+ cc_ldflags => '', # prefix for ldflags (necessary for Win32)
+ # Huh? This isn't used anywhere.
+ # Don't use this. I don't know what it means.
# 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.
+ # Create an executable with
+ # $link $linkflags $link_debug ${link_out}file${exe} file${o} $libs
+ # If you have multiple object files, VMS needs to have them
+ # separated by commas, like this: (and all on one line)
+ # $link $linkflags $link_debug ${link_out}file${exe} \
+ # file1${o},file2${o} $libs
link => $Config{cc},
linkflags => $Config{ldflags},
+ link_debug => '',
+ link_out => '-o ', # linker output file.
# ld: Tool used to build dynamically loadable libraries. Often
# $cc on Unix-ish systems, but apparently sometimes it's ld.
+ # XXX The exact usage has not been determined yet.
ld => $Config{ld},
ldflags => $Config{ldflags},
+ ld_out => '-o ', # ld output file.
+ ld_debug => '', # include debug info in executable
+ ld_shared => $Config{lddlflags}, # Any flags specifically
+ # needed to instruct ld to create
+ # a shared libary.
+ ld_shared_flags=> '', # What is this, exactly? For GNU ld, it was
+ # '-Wl,-soname,libparrot$(SO)'
libs => $Config{libs},
- 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
+ so => '.so', # dynamic link library or
+ # shared object extension
a => '.a', # library or archive extension
exe => $Config{_exe}, # executable files extension
- cc_o_out => '-o ', # cc object output file
- cc_exe_out => '-o ', # cc executable output file (different on
Win32)
-
- cc_ldflags => '', # prefix for ldflags (necessary for Win32)
- ld_out => '-o ', # ld output file
- ld_debug => '', # include debug info in executable
- ld_shared => $Config{lddlflags},
- ld_shared_flags=> '', # What is this, exactly? For GNU ld, it was
- # '-Wl,-soname,libparrot$(SO)'
# should we have a dependancy upon arc to generate .a's?
blib_lib_libparrot_a => 'blib/lib/libparrot$(A)',
diff -r -u parrot-orig/config/init/hints/darwin.pl
parrot-andy/config/init/hints/darwin.pl
--- parrot-orig/config/init/hints/darwin.pl Fri Jun 7 15:21:17 2002
+++ parrot-andy/config/init/hints/darwin.pl Thu Oct 31 08:57:22 2002
@@ -4,6 +4,9 @@
$ccflags =~ s/-flat_namespace\s*//;
$ldflags =~ s/-flat_namespace\s*//;
$ldflags .= " -flat_namespace ";
+# Guess at what's needed for linking. (See config/init/data.pl.)
+$linkflags =~ s/-flat_namespace\s*//;
+$linkflags .= " -flat_namespace ";
Configure::Data->set(
ccflags => $ccflags,
diff -r -u parrot-orig/config/init/hints/mswin32.pl
parrot-andy/config/init/hints/mswin32.pl
--- parrot-orig/config/init/hints/mswin32.pl Wed Oct 16 16:32:21 2002
+++ parrot-andy/config/init/hints/mswin32.pl Thu Oct 31 10:03:45 2002
@@ -1,3 +1,4 @@
+# See config/init/data.pl for definitions of the various variables.
{
my($cc, $ccflags, $libs)=Configure::Data->get(qw(cc ccflags libs));
my $is_msvc = grep { $cc eq $_ } ( qw(cl cl.exe) );
@@ -24,16 +25,25 @@
so => '.dll',
a => '.lib',
o => '.obj',
+ # Compiler flags
cc_o_out => '-Fo',
- cc_exe_out => '-Fe',
- cc_ldflags => '/link',
- #Use Edit and Continue debugging if available
+ cc_exe_out => '-Fe', # Shouldn't be used.
+ cc_ldflags => '/link', # Unused.
+ #Use Edit and Continue debugging if available
cc_debug => ($cc_output =~ /-ZI/? '-ZI' : '-Zi'),
+
+ # Shared-library builder flags
ld_debug => '-debug',
ld_shared => '-dll',
ld_shared_flags=> '-def:libparrot.def',
ld_out => '-out:',
ldflags => '-nologo',
+
+ # Linker flags
+ linkflags => '-nologo',
+ link_debug => '-debug',
+ link_out => '-out:',
+
blib_lib_libparrot_a => '',
cp => 'copy',
slash => '\\',
@@ -46,19 +56,27 @@
if( $is_bcc ) {
Configure::Data->set(
o => '.obj',
+ # Compiler flags
ccflags => '-O2 -w-8066 -DWIN32 -DNO_STRICT -DNDEBUG
-D_CONSOLE',
- cc_o_out => '-o',
- cc_exe_out => '-e',
+ cc_o_out => '-o '
+ cc_exe_out => '-e', # Shouldn't be used.
+ cc_ldflags => '', # Unused.
cc_debug => '-v',
+ # Shared-library builder flags XXX CHECK THESE!
ld => 'bcc32.exe',
ldflags => '',
ld_out => '-e',
- cc_ldflags => '',
ld_debug => '-v',
ld_shared => '-WD',
libs => 'import32.lib cw32.lib',
+ # Linker flags XXX CHECK THESE!
+ link => 'bcc32.exe',
+ linkflags => '',
+ link_debug => '-v',
+ link_out => '-e',
+
cp => 'copy',
slash => '\\'
);
@@ -70,4 +88,4 @@
libs => $libs
);
}
-}
\ No newline at end of file
+}
diff -r -u parrot-orig/config/init/hints/os2.pl parrot-andy/config/init/hints/os2.pl
--- parrot-orig/config/init/hints/os2.pl Fri May 24 02:24:27 2002
+++ parrot-andy/config/init/hints/os2.pl Thu Oct 31 09:14:10 2002
@@ -8,5 +8,6 @@
opcode_t =>"long",
ccflags => "-I. -fno-strict-aliasing -mieee-fp -I./include",
ldflags => "-Zexe",
+ linkflags => "-Zexe",
perl => "perl" # avoids case-mangling in make
);
diff -r -u parrot-orig/config/init/hints/vms.pl parrot-andy/config/init/hints/vms.pl
--- parrot-orig/config/init/hints/vms.pl Fri May 24 02:24:27 2002
+++ parrot-andy/config/init/hints/vms.pl Thu Oct 31 11:54:17 2002
@@ -1,12 +1,25 @@
+# See config/init/data.pl for definitions of the various variables.
Configure::Data->set(
ccflags =>
qq{/Standard=Relaxed_ANSI/Prefix=All/Obj=.obj/NoList/NOANSI_ALIAS/include="./include"},
perl => "MCR $^X",
- exe => "exe"
+ exe => "exe",
+ # Compiler flags
+ cc_c => '',
+ cc_inc => '/INCLUDE=[.include]',
+ # Linker flags
+ link => "link",
+ link_out => '/exe='
);
{
local $^W; #no warnings on redefinition
+ # Ultimately, we should try to move these back to
+ # Parrot::Configure::Step. The abstractions required would likely
+ # be useful for supporting cross-compilation as well.
+ # (Apart from error re-directions issues, the first one probably
+ # already could be moved back now that Configure properly
+ # distinguishes among cc, link, and ld.)
*Parrot::Configure::Step::cc_build=sub {
system("$c{cc} $c{ccflags} test.c") and die "C compiler died!";
system("link/exe=test test") and die "Link failed!";
--
Andy Dougherty [EMAIL PROTECTED]