This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix building with Sun CC breakage.
- From: "Pedro Alves" <pedro_alves at portugalmail dot pt>
- To: binutils at sourceware dot org
- Date: Thu, 25 Oct 2007 15:32:10 +0100
- Subject: Fix building with Sun CC breakage.
Hi guys,
For a while now, it hasn't been possible to build binutils with Sun CC.
$cc -V
cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
It bails out with this:
/bin/bash ./libtool --tag=CC --mode=compile cc -DHAVE_CONFIG_H -I.
-I../../binutils-2.18.50/bfd -I. -I. -I../../binutils-2.18.50/bfd
-I../../binutils-2.18.50/bfd/../include -I./../intl -g -c -o
elf.lo ../../binutils-2.18.50/bfd/elf.c
libtool: compile: cc -DHAVE_CONFIG_H -I. -I../../binutils-2.18.50/bfd
-I. -I. -I../../binutils-2.18.50/bfd
-I../../binutils-2.18.50/bfd/../include -I./../intl -g -c
../../binutils-2.18.50/bfd/elf.c -o elf.o
"../../binutils-2.18.50/bfd/elf.c", line 856: non-constant initializer: op "?"
"../../binutils-2.18.50/bfd/elf.c", line 859: non-constant initializer: op "?"
"../../binutils-2.18.50/bfd/elf.c", line 864: non-constant initializer: op "?"
"../../binutils-2.18.50/bfd/elf.c", line 871: non-constant initializer: op "?"
"../../binutils-2.18.50/bfd/elf.c", line 993: cannot recover from
previous errors
That comes from usage of STRING_COMMA_LEN which is defined as:
bfd-in.h:#define STRING_COMMA_LEN(STR) (STR), ((STR) ? sizeof (STR) - 1 : 0)
It turns out that supporting a NULL STR doesn't have much value, as it is
only used 6 times:
$egrep -e "STRING_COMMA_LEN \(([A-Z]|[a-z]|0|_)" * -rn
ld/pe-dll.c:198: { STRING_COMMA_LEN (NULL) }
ld/pe-dll.c:234: { STRING_COMMA_LEN (NULL) }
ld/pe-dll.c:324: { STRING_COMMA_LEN (NULL) }
ld/pe-dll.c:339: { STRING_COMMA_LEN (NULL) }
ld/pe-dll.c:353: { STRING_COMMA_LEN (NULL) }
ld/pe-dll.c:359: { STRING_COMMA_LEN (NULL) }
The attached patches inline those usages, and remove the support
for passing a NULL STR, making Sun CC happy again.
Cheers,
Pedro Alves
bfd/
2007-10-25 Pedro Alves <pedro_alves@portugalmail.pt>
* bfd-in.h (STRING_COMMA_LEN): Don't handle NULL STR case.
* bfd-in2.h: Regenerate.
---
bfd/bfd-in.h | 5 ++---
bfd/bfd-in2.h | 5 ++---
2 files changed, 4 insertions(+), 6 deletions(-)
Index: binutils-2.18.50/bfd/bfd-in.h
===================================================================
--- binutils-2.18.50.orig/bfd/bfd-in.h 2007-10-25 14:41:47.927945000 +0100
+++ binutils-2.18.50/bfd/bfd-in.h 2007-10-25 14:42:07.690856000 +0100
@@ -46,9 +46,8 @@ extern "C" {
/* This is a utility macro to handle the situation where the code
wants to place a constant string into the code, followed by a
comma and then the length of the string. Doing this by hand
- is error prone, so using this macro is safer. The macro will
- also safely handle the case where a NULL is passed as the arg. */
-#define STRING_COMMA_LEN(STR) (STR), ((STR) ? sizeof (STR) - 1 : 0)
+ is error prone, so using this macro is safer. */
+#define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
/* Unfortunately it is not possible to use the STRING_COMMA_LEN macro
to create the arguments to another macro, since the preprocessor
will mis-count the number of arguments to the outer macro (by not
Index: binutils-2.18.50/bfd/bfd-in2.h
===================================================================
--- binutils-2.18.50.orig/bfd/bfd-in2.h 2007-10-25 14:41:47.999578000 +0100
+++ binutils-2.18.50/bfd/bfd-in2.h 2007-10-25 14:42:07.747176000 +0100
@@ -53,9 +53,8 @@ extern "C" {
/* This is a utility macro to handle the situation where the code
wants to place a constant string into the code, followed by a
comma and then the length of the string. Doing this by hand
- is error prone, so using this macro is safer. The macro will
- also safely handle the case where a NULL is passed as the arg. */
-#define STRING_COMMA_LEN(STR) (STR), ((STR) ? sizeof (STR) - 1 : 0)
+ is error prone, so using this macro is safer. */
+#define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
/* Unfortunately it is not possible to use the STRING_COMMA_LEN macro
to create the arguments to another macro, since the preprocessor
will mis-count the number of arguments to the outer macro (by not
ld/
2007-10-25 Pedro Alves <pedro_alves@portugalmail.pt>
* pe-dll.c (autofilter_symbollist_generic)
(autofilter_symbollist_i386, autofilter_liblist)
(autofilter_objlist, autofilter_symbolprefixlist)
(autofilter_symbolsuffixlist): Don't use STRING_COMMA_LEN with
NULL.
---
ld/pe-dll.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: binutils-2.18.50/ld/pe-dll.c
===================================================================
--- binutils-2.18.50.orig/ld/pe-dll.c 2007-10-25 14:41:48.048788000 +0100
+++ binutils-2.18.50/ld/pe-dll.c 2007-10-25 14:42:27.386415000 +0100
@@ -195,7 +195,7 @@ static const autofilter_entry_type autof
/* Runtime pseudo-reloc. */
{ STRING_COMMA_LEN ("_pei386_runtime_relocator") },
{ STRING_COMMA_LEN ("do_pseudo_reloc") },
- { STRING_COMMA_LEN (NULL) }
+ { NULL, 0 }
};
static const autofilter_entry_type autofilter_symbollist_i386[] =
@@ -231,7 +231,7 @@ static const autofilter_entry_type autof
{ STRING_COMMA_LEN ("_impure_ptr") },
{ STRING_COMMA_LEN ("_fmode") },
{ STRING_COMMA_LEN ("environ") },
- { STRING_COMMA_LEN (NULL) }
+ { NULL, 0 }
};
#define PE_ARCH_i386 1
@@ -321,7 +321,7 @@ static const autofilter_entry_type autof
{ STRING_COMMA_LEN ("libsupc++") },
{ STRING_COMMA_LEN ("libobjc") },
{ STRING_COMMA_LEN ("libgcj") },
- { STRING_COMMA_LEN (NULL) }
+ { NULL, 0 }
};
static const autofilter_entry_type autofilter_objlist[] =
@@ -336,7 +336,7 @@ static const autofilter_entry_type autof
{ STRING_COMMA_LEN ("gcrt2.o") },
{ STRING_COMMA_LEN ("crtbegin.o") },
{ STRING_COMMA_LEN ("crtend.o") },
- { STRING_COMMA_LEN (NULL) }
+ { NULL, 0 }
};
static const autofilter_entry_type autofilter_symbolprefixlist[] =
@@ -350,13 +350,13 @@ static const autofilter_entry_type autof
{ STRING_COMMA_LEN ("_nm_") },
/* Don't export symbols specifying internal DLL layout. */
{ STRING_COMMA_LEN ("_head_") },
- { STRING_COMMA_LEN (NULL) }
+ { NULL, 0 }
};
static const autofilter_entry_type autofilter_symbolsuffixlist[] =
{
{ STRING_COMMA_LEN ("_iname") },
- { STRING_COMMA_LEN (NULL) }
+ { NULL, 0 }
};
#define U(str) (pe_details->underscored ? "_" str : str)