This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC,PATCH] Extend MULTILIB_EXCEPTIONS with a check for absent options


Hello,

(I have been trying to send this to the list several times but the
email does for some reason not appear in the archive.  So sorry in
advance for the duplicates in case they will ever made it to the
list.)

As I wrote in another email
(http://gcc.gnu.org/ml/gcc/2008-06/msg00053.html) I'm trying to built
a DFP hardware variant of libgcc_s for S/390.  Hardware DFP is enabled
on S/390 with the z9-ec machine running in z/Architecture mode.  So I
need two options for this: -march=z9-ec and -mzarch.  Basically the
target is to have 4 versions of libgcc built with:

-m31
-m64
-m31 -march=z9-ec -mzarch
-m64 -march=z9-ec -mzarch

Since -m64 and -mzarch are default options the last variant could also
be compiled with simply -march=z9-ec but for the -m31 version the
-mzarch option is mandatory since -m31 otherwise switches to -mesa.

I've added the new options to MULTILIB_OPTIONS and *one* path to the
DIRNAMES variables.  Since I don't want the dfp lib to be placed in
dfp/dfp I've left the fourth value empty.

MULTILIB_OPTIONS = m64/m31 march=z9-ec mzarch
MULTILIB_DIRNAMES = 64 32 dfp
MULTILIB_OSDIRNAMES = ../lib64 ../lib dfp

genmultilib generates a multilib.h containing these lines:

   static const char *const multilib_raw[] = {
1. ". !m64 !m31 !march=z9-ec !mzarch;",
2. "64:../lib64 m64 !m31 !march=z9-ec !mzarch;",
3. "32:../lib !m64 m31 !march=z9-ec !mzarch;",
4. "dfp:dfp !m64 !m31 march=z9-ec !mzarch;",
5. ": !m64 !m31 !march=z9-ec mzarch;",
6. "dfp/:dfp/ !m64 !m31 march=z9-ec mzarch;",
7. "64/dfp:../lib64/dfp m64 !m31 march=z9-ec !mzarch;",
8. "64/:../lib64/ m64 !m31 !march=z9-ec mzarch;",
9. "64/dfp/:../lib64/dfp/ m64 !m31 march=z9-ec mzarch;",
10."32/dfp:../lib/dfp !m64 m31 march=z9-ec !mzarch;",
11."32/:../lib/ !m64 m31 !march=z9-ec mzarch;",
12."32/dfp/:../lib/dfp/ !m64 m31 march=z9-ec mzarch;",
   NULL
   };

Several of these lines are used by -print-multi-lib and others (while
redundant) are used by -print-multi-os-directory.  Actually it took me
quite a while to figure out which of these lines affect which
option. The difference in behaviour basically results from different
handling of default options in print_multilib_info and
set_multilib_dir in gcc.c.

While trying to get rid of the invalid march=z9-ec/mzarch pairs I
found both of the existing mechanisms to be insufficient (EXCEPTION
and EXCLUSION).

Let's take line 5 as example: ": !m64 !m31 !march=z9-ec mzarch;",

With MULTILIB_EXCEPTIONS it is only possible to avoid certain
combinations of options but it is not possible to match the absence of
an option. So this doesn't help here since there is just a single
option marked as required (mzarch).

MULTILIB_EXCLUSIONS allows the ! prefix for options which should not
be present.  Besides this also default options are taken into account.
Therefore the exclusion string "!m64/!m31/!march=z9-ec/mzarch" does
*not* match since m64 is a default option.  But trying to use just
"!m31/!march=z9-ec/mzarch" also disables line 9 which is needed for
the os dirname of the hardware dfp variant.

In order to get the required effect I wrote a small patch for
genmultilib which allows the ! prefix also in the MULTILIB_EXCEPTION
strings.  With this and the "obvious" exceptions:

MULTILIB_EXCEPTIONS = !m64/m31/march=z9-ec/mzarch
!m64/m31/!march=z9-ec/mzarch m64/!m31/march=z9-ec/!mzarch
!m64/!m31/!march=z9-ec/mzarch !m64/!m31/march=z9-ec/!mzarch

I got the multilibs I was trying to build.

The big advantage of the patch is that if someone now wants to remove
a line of multilib.h he just has to copy and paste the options line to
MULTILIB_EXCEPTIONS and replace the blanks with slashes.  I found that
quite handy while identifying the necessary lines in multlib.h.

The patch comes without documentation and proper testing for now.  But
I'll of course adjust the manual pieces regarding MULTILIB_EXCEPTIONS
if the patch should be accepted.

Ok for mainline?

P.S.: Any opinions regarding the other problem described in:
http://gcc.gnu.org/ml/gcc/2008-06/msg00053.html

I've currently solved this by adding symlinks from /usr/lib/dfp to
/usr/lib and from /usr/lib64/dfp to /usr/lib64 but I think we do need
a general solution for this.  In case the existing variables do not
provide a solution I would like to split the MULTILIB_OSDIRNAMES
variable into two.  One for the location where to look for the
multilibbed OS libs and one for the install location of libgcc_s.so.
Does this make sense?

Bye,

-Andreas-

Index: gcc/genmultilib
===================================================================
*** gcc/genmultilib.orig	2008-06-11 18:24:35.000000000 +0200
--- gcc/genmultilib	2008-06-11 18:26:04.000000000 +0200
*************** if [ -n "${exceptions}" ]; then
*** 179,194 ****
  # a list of subdirectory names with leading and trailing slashes.
  
    for opt in $@; do
-     case "$opt" in
  EOF
  
    for except in ${exceptions}; do
!     echo "      /${except}/) : ;;" >> tmpmultilib2
    done
  
  cat >>tmpmultilib2 <<\EOF
!       *) echo ${opt};;
!     esac
    done
  EOF
    chmod +x tmpmultilib2
--- 179,196 ----
  # a list of subdirectory names with leading and trailing slashes.
  
    for opt in $@; do
  EOF
  
    for except in ${exceptions}; do
!     echo -n "    test -n \"" >> tmpmultilib2
!     echo -n '`echo $opt ' >> tmpmultilib2
!     echo -n "/${except}" | sed -e 's#/\([^/]*\)#| grep "/\1/"#g' \
!             -e 's#"/!#-v "/#g' -e 's|*|[^/]*|g' >> tmpmultilib2
!     echo "\`\" && continue" >> tmpmultilib2
    done
  
  cat >>tmpmultilib2 <<\EOF
!     echo $opt
    done
  EOF
    chmod +x tmpmultilib2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]