Skip to content

Commit

Permalink
[config] fix --m=64 logic with gcc, GH #1181
Browse files Browse the repository at this point in the history
- Tested on debian multilib powerpc64, analog to the previous
  mips64 fixes in #1110.
- Fix the missing space after lib64. See GH #1181.
- Add analog fixes for arm and sparc also, untested.
- Change more wrong libpaths: also libdir embed-ldflags
  inst_libparrot_linkflags rpath_lib

Note that cc_build still uses wrong paths, as icu is still
falsely detected.
  • Loading branch information
Reini Urban committed Jan 20, 2015
1 parent 0809f74 commit a7ed5cc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
9 changes: 5 additions & 4 deletions config/auto/arch.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2001-2014, Parrot Foundation.
# Copyright (C) 2001-2015, Parrot Foundation.

=head1 NAME
Expand All @@ -10,8 +10,9 @@ Determines the CPU architecture, the operating system.
This code was formerly part of configuration step class auto::jit.
TODO #356: This checks for the perl5 architecture, not for possible
commandline overrides, such as -m64, -m32 or -Wl,-melf_x86_64.
This checks for the inherited perl5 architecture, not for possible
commandline overrides, such as -m64, -m32, mabi=64 or -Wl,-melf_x86_64.
See auto::gcc for those as they are compiler specific. (TT 356, GH #1181)
=cut

Expand Down Expand Up @@ -76,7 +77,7 @@ sub runstep {
$osname = 'MSWin32';
}
elsif ( $osname =~ /cygwin/i || $cpuarch =~ /cygwin/i ) {
$cpuarch = 'x86'; # 64 how?
$cpuarch = 'x86'; # TODO 64 how?
$osname = 'cygwin';
}
elsif ( $osname =~ /msys/i || $cpuarch =~ /msys/i ) {
Expand Down
38 changes: 25 additions & 13 deletions config/auto/gcc.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2001-2014, Parrot Foundation.
# Copyright (C) 2001-2015, Parrot Foundation.

=head1 NAME
Expand Down Expand Up @@ -89,31 +89,43 @@ sub _evaluate_gcc {
my $m = $conf->options->get('m');
if ($m) {
my $archname = $conf->data->get('archname');
# other multilib platforms usually default to 32bit. untested: sparc64, arm64
if ( $archname =~ /^(mips|powerpc)64/ && $m eq '32' ) {
# other multilib platforms usually default to 32bit.
# untested: sparc64, arm64
if ( $archname =~ /^(mips|powerpc|arm|sparc)64/ && $m eq '32' ) {
my $abi = $1 eq 'mips' ? '-mabi=32' : '-m32';
$archname =~ s/64//;
for my $cc (qw(cc cxx link ld)) {
$conf->data->add( ' ', $cc, $abi );
}
# and lib flags
for my $lib (qw(ld_load_flags ld_share_flags ldflags linkflags)) {
# and lib flags: lib64 => lib
for my $lib (qw(ld_load_flags ld_share_flags ldflags linkflags
libdir embed-ldflags inst_libparrot_linkflags rpath_lib)) {
my $item = $conf->data->get($lib);
( my $ni = $item ) =~ s/lib64/lib/g;
$conf->data->set( $lib, $ni );
# TODO: if lib32 exists use that
if ($item) {
my $olditem = $item;
$item =~ s/lib64/lib/g;
$conf->data->set( $lib, $item ) if $olditem ne $item;
}
}
}
elsif ( $archname =~ /^(mips|powerpc)/ && $m eq '64' ) {
# GH #1181: override the default, ignore the inherited libpaths.
elsif ( $archname =~ /^(mips|powerpc|arm|sparc)/ && $m eq '64' ) {
my $abi = $1 eq 'mips' ? '-mabi=64' : '-m64';
$archname =~ s/(s|c)$/$164/;
# 'mips' or 'powerpc-linux-gnu-thread-multi'
$archname =~ s/(mips|powerpc|arm|sparc)([^6]|$)/${1}64${2}/;
for my $cc (qw(cc cxx link ld)) {
$conf->data->add( ' ', $cc, $abi );
}
# and lib flags
for my $lib (qw(ld_load_flags ld_share_flags ldflags linkflags)) {
# and lib flags: lib or libx32 or lib32 => lib64
for my $lib (qw(ld_load_flags ld_share_flags ldflags linkflags
libdir embed-ldflags inst_libparrot_linkflags rpath_lib)) {
my $item = $conf->data->get($lib);
( my $ni = $item ) =~ s{lib\W}{lib64}g;
$conf->data->set( $lib, $ni );
if ($item) {
my $olditem = $item;
$item =~ s/\/lib([^6]|$)/\/lib64${1}/g;
$conf->data->set( $lib, $item ) if $olditem ne $item;
}
}
}
$conf->data->set( 'archname', $archname );
Expand Down

0 comments on commit a7ed5cc

Please sign in to comment.