Bug 12764 - gcc -g option leaves asterisk (*) on some names to assembler on HP-UX B.10.20
Summary: gcc -g option leaves asterisk (*) on some names to assembler on HP-UX B.10.20
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-10-24 16:52 UTC by mario.nigrovic
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: hppa2.0-hp-hpux10.20
Target: hppa2.0-hp-hpux10.20
Build: hppa2.0-hp-hpux10.20
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Call assemble_name on the function name. (402 bytes, patch)
2003-10-24 19:09 UTC, mario.nigrovic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mario.nigrovic 2003-10-24 16:52:48 UTC
Here's a faulty snippit of code I got trying to compile make 3.80 with gcc 3.3.1
on an HPUX machine.  The problem seems to be that the "*" is not removed from
the function symbol name glob64:

glob64
        .PROC
        .CALLINFO FRAME=320,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=18
        .ENTRY
        stw %r2,-20(%r30)
        copy %r3,%r1
        .stabn 68,0,375,L$M17-*glob64
L$M17:

I've looked into this a bit, and it would seem that the .stabn line with the
problem is being created in .../gcc-3.3.1/gcc/config/pa/som.h, around line 39. 
I've looked at some corresponding code for other architectures and they all seem
to surround the XSTR with a call to assemble_name(FILE, XSTR ... ).  This line
is a bit curious because it ends with a "+ 1" to a string, which I assume is the
old way to get past the leading _ or other character on symbol names.

For now, I'm working around this by removing the -g from all compiles, but
that's not a great long-term solution...

I'm going to try a crack at fixing this code myself, and if I can solve the
problem, I'll add a diff or whatever to this bug report.

REPRODUCING

.../make-3.80/configure --prefix=$PWD/install --disable-nls
make

make exits with something like

Command: make
make  all-recursive
make[1]: Entering directory `/tmp/make.2a'
Making all in glob
make[2]: Entering directory `/tmp/make.2a/glob'
if gcc -DHAVE_CONFIG_H -I. -I/media/gnu/make-3.80/glob -I..     -g -O2 -MT
glob.o -MD -MP -MF ".deps/glob.Tpo" \
  -c -o glob.o `test -f '/media/gnu/make-3.80/glob/glob.c' || echo
'/media/gnu/make-3.80/glob/'`/media/gnu/make-3.80/glob/glob.c; \
then mv ".deps/glob.Tpo" ".deps/glob.Po"; \
else rm -f ".deps/glob.Tpo"; exit 1; \
fi
In file included from /media/gnu/make-3.80/glob/glob.c:203:
/media/gnu/make-3.80/glob/glob.c: In function `glob':
/media/gnu/make-3.80/glob/glob.c:197: warning: passing arg of `my_realloc' from
incompatible pointer type
In file included from /media/gnu/make-3.80/glob/glob.c:203:
/media/gnu/make-3.80/glob/glob.c:197: warning: passing arg of `my_realloc' from
incompatible pointer type
In file included from /media/gnu/make-3.80/glob/glob.c:203:
/media/gnu/make-3.80/glob/glob.c:197: warning: passing arg of `my_realloc' from
incompatible pointer type
In file included from /media/gnu/make-3.80/glob/glob.c:203:
/media/gnu/make-3.80/glob/glob.c: In function `glob_in_dir':
/media/gnu/make-3.80/glob/glob.c:197: warning: passing arg of `my_realloc' from
incompatible pointer type
/var/tmp//ccm47IgT.s: Assembler messages:
/var/tmp//ccm47IgT.s:641: Error: bad expression
/var/tmp//ccm47IgT.s:641: Warning: rest of line ignored; first ignored character
is `g'
/var/tmp//ccm47IgT.s:647: Error: bad expression
/var/tmp//ccm47IgT.s:647: Warning: rest of line ignored; first ignored character
is `g'
/var/tmp//ccm47IgT.s:670: Error: bad expression
/var/tmp//ccm47IgT.s:670: Warning: rest of line ignored; first ignored character
is `g'
Comment 1 Andrew Pinski 2003-10-24 16:56:23 UTC
Are you using GNU binutils or the native toolchain?
Also how did you configure gcc?
How did you build gcc?
Comment 2 mario.nigrovic 2003-10-24 17:24:38 UTC
Sorry I didn't include this before.  GNU binutils (as only, ld is not supported
for this platform).

++ as --version
GNU assembler 2.14 20030612
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
This assembler was configured for a target of `hppa2.0-hp-hpux10.20'.

++ gcc -v
Reading specs from /tmp/GNU_temp/lib/gcc-lib/hppa2.0-hp-hpux10.20/3.3.1/specs
Configured with: /media/gnu/gcc-3.3.1/configure --prefix=/tmp/GNU_temp
--enable-languages=c,c++ --disable-nls --with-gnu-as
--with-as=/tmp/GNU_temp/bin/as --without-gnu-ld
Thread model: single
gcc version 3.3.1


I have the configure and make logs, if you're interested, but they're huge...

The compiler used to build the new binutils and gcc is

++ /tools/GNU/003/HP-UX_B.10.20/bin/gcc -v
Reading specs from
/tools/GNU/003/HP-UX_B.10.20/lib/gcc-lib/hppa2.0-hp-hpux10.20/3.0.4/specs
Configured with: /media/gnu/gcc-3.0.4/configure
--prefix=/tools/GNU/003/HP-UX_B.10.20 --with-gnu-as
--with-as=/tools/GNU/003/HP-UX_B.10.20/bin/as --with-gnu-ld
--with-ld=/tools/GNU/003/HP-UX_B.10.20/bin/ld
Thread model: single
gcc version 3.0.4

Comment 3 mario.nigrovic 2003-10-24 19:09:31 UTC
Created attachment 4989 [details]
Call assemble_name on the function name.

Whether the local labels should also be subjected to assemble_name is
unresolved.  I think it's a completeness issue more than a current problem.
Comment 4 Andrew Pinski 2003-10-25 02:37:03 UTC
Can you update your patch for the mainline and post it to gcc-patches@gcc.gnu.org with a 
changelog?
Comment 5 mario.nigrovic 2003-10-26 20:08:46 UTC
I looked at the current cvs, and it seems to have already been addressed.  The
new syntax is

#define ASM_OUTPUT_SOURCE_LINE(file, line, counter)		\
  { static tree last_function_decl = NULL;			\
    if (current_function_decl == last_function_decl)		\
      {								\
	rtx func = DECL_RTL (current_function_decl);		\
	const char *name = XSTR (XEXP (func, 0), 0);		\
	fprintf (file, "\t.stabn 68,0,%d,L$M%d-%s\nL$M%d:\n",	\
		 line, counter,					\
		 (* targetm.strip_name_encoding) (name),	\
		 counter);					\
      }								\
    else							\
      fprintf (file, "\t.stabn 68,0,%d,0\n", line);		\
    last_function_decl = current_function_decl;			\
  }


which is quite a bit different from my solution, but at least means this has
been looked at.  Looking at dbxelf.h, I do see that it's handled differently, there:

#define ASM_OUTPUT_SOURCE_LINE(FILE, LINE, COUNTER)			\
do									\
  {									\
    char temp[256];							\
    ASM_GENERATE_INTERNAL_LABEL (temp, "LM", COUNTER);			\
    fprintf (FILE, "\t.stabn 68,0,%d,", LINE);				\
    assemble_name (FILE, temp);						\
    putc ('-', FILE);							\
    assemble_name (FILE,						\
		   XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
    putc ('\n', FILE);							\
    (*targetm.asm_out.internal_label) (FILE, "LM", COUNTER);		\
  }									\
while (0)

(It's still using assemble_name for the function name.  I don't pretend to
understand the subtleties of this variation, but I guess it does seem suspicious
to me that the implementation is so different.)

-- Mario
Comment 6 Andrew Pinski 2003-10-26 20:24:02 UTC
Fixed by a different patch so closing.