Ticket #838 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

Configure.pl mangles forwardslashed-flags for CL

Reported by: whiteknight Owned by: coke
Priority: normal Milestone:
Component: configure Version: 1.3.0
Severity: medium Keywords:
Cc: jkeenan Language:
Patch status: Platform: win32

Description

The Microsoft C compiler, cl, takes flags with a forward slash instead of a - on Linux. Configure.pl helpfully mangles these forward slashes into backslashes in the makefile, I think it's mixing up the --ccflags with some kind of path specifier.

For instance, I typed this:

Configure.pl --ccflags="/GS- /MD"

And the makefile contained this:

CONFIG_ARGS     = "--ccflags=\GS- \MD"

I had to manually edit this in the makefile here and one other place to make this work.

Change History

  Changed 5 years ago by jkeenan

  • cc jkeenan added

Some data points:

In config/init/defaults.pm, ccflags gets assigned the value of the same attribute in %Config of the Perl 5 used to run Configure.pl.

        ccflags => $Config{ccflags},

In config/init/hints/mswin32.pm, the value is pulled in from the command-line option, if specified, or pulled from the Parrot::Configure object if not:

    my $ccflags   = $conf->option_or_data('ccflags');

Then, depending on what compiler you're using, various modifications are -- or are not -- made to the value:

    if ($is_msvc) {
...
        $ccflags =~ s/-O1 // if $cc_output =~ m/Standard/ || $cc_output =~ m{/ZI};
        unless ($msvcversion) { $cc_output =~ m/Version (\d+)/; $msvcversion = $1; }
        $ccflags =~ s/-Gf/-GF/ if $msvcversion >= 13;

        # override perl's warnings level
        $ccflags =~ s/-W\d/-W4/;

        # if we want pbc_to_exe to work, need to let some versions of the
        # compiler use more memory than they normally would
        $ccflags .= " -Zm1500 " if $msvcversion < 13;
...
        $conf->data->set(
...
            ccflags             => $ccflags,
...
    }       
    elsif ($is_intel) {
        $conf->data->set( 
...
            ccflags             => $ccflags,
...
    }       
    elsif ($is_mingw) {
        my $make = $conf->data->get(qw(make));        if ( $make =~ /nmake/i ) {
...
            # ActiveState Perl
            $conf->data->set(
...
                ccflags => '-DWIN32 ',
...
        }        elsif ( $make =~ /dmake/i ) {
            # strawberry Perl
            $conf->data->set(
                ccflags   => '-DWIN32 ',
...

Then, this appears to be overrideable in interactive mode in config/inter/progs.pm:

    $ccflags = integrate( $conf->data->get('ccflags'),
        $conf->options->get('ccflags') );

    # Remove some perl5-isms.
    $ccflags =~ s/-D((PERL|HAVE)_\w+\s*|USE_PERLIO)//g;
    $ccflags =~ s/-fno-strict-aliasing//g;
    $ccflags =~ s/-fnative-struct//g;
    $ccflags = prompt( "What flags should your C compiler receive?", $ccflags )
        if $ask;
    $conf->data->set( ccflags => $ccflags );

    $verbose and print " ccflags: $ccflags\n";

Various flags are added to ccflags in several of the config/auto/*.pm probes. Doesn't affect the fundamentals, AFAICT.

ccflags then appears in the following places in files under config/gen/:

config/gen/makefiles/root.in:106:CFLAGS           := $(CC_INC) @ccflags@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@ $(CC_SHARED)
config/gen/makefiles/root.in:2144:  $(PERL) Configure.pl --ccflags="$(CC_FLAGS) $(COVER_FLAGS)" \
config/gen/makefiles/dynpmc_pl.in:36:our $CFLAGS          = q[@ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@];config/gen/makefiles/dynpmc.in:17:CFLAGS        := @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@config/gen/makefiles/pirc.in:20:CFLAGS        := $(CC_INC) @ccflags@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@ $(CC_SHARED)
config/gen/makefiles/dynoplibs_pl.in:32:our $CFLAGS = q[@ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@];
config/gen/makefiles/dynoplibs.in:17:CFLAGS        := @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
config/gen/config_pm/myconfig.in:10:    cc='@cc@', ccflags='@ccflags@',
config/gen/config_pm.pm:102:    my @p5_keys_whitelist = qw(archname ccflags longsize optimize);

HTH

kid51

in reply to: ↑ description ; follow-up: ↓ 5   Changed 5 years ago by jkeenan

Replying to whiteknight:

Can you provide output of grep -ni ccflags lib/Parrot/Config/Generated.pm config_lib.pasm on this box?

Can you provide more details on MS cl compiler? I'll bet many of us have never heard of it. What is its relation to/difference from MSVC, Intel C compiler, etc?

kid51

in reply to: ↑ description   Changed 5 years ago by jkeenan

Replying to whiteknight:

You may want to look at: gen::makefiles::makefiles() and Parrot::Configure::Compiler::genfile().

  Changed 5 years ago by particle

cl also accepts options with a dash instead of a slash, use those instead to avoid the configure's slashie-mangling.

try

perl Configure.pl --ccflags="-GS- -MD"

and see what happens.

in reply to: ↑ 2   Changed 5 years ago by particle

Replying to jkeenan:

Can you provide more details on MS cl compiler? I'll bet many of us have never heard of it. What is its relation to/difference from MSVC, Intel C compiler, etc?

cl.exe is the c/c++ compiler executable for msvc.

  Changed 5 years ago by coke

  • owner set to coke

I believe this is fixed in the rm_cflags branch - it removes the global / \ conversion that was happening, and uses the config @slash@ where appropriate.

  Changed 5 years ago by particle

  • status changed from new to closed
  • resolution set to fixed

this has been fixed in the rm_cflags branch, which has since been merged to trunk. i cannot replicate this with r44660.

Note: See TracTickets for help on using tickets.