Issue Details (XML | Word | Printable)

Key: PCC-90
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Detlef Riekenberg
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
pcc

asm redirection need __USER_LABEL_PREFIX__

Created: 25/Aug/09 01:24 PM   Updated: 31/Aug/10 07:29 PM
Component/s: C preprocessor
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. Text File _configure.txt (108 kB)
2. Text File config.log (2.67 MB)

Environment: i386-linux


 Description  « Hide
C functions are redirected to asm functions in <sys/cdefs.h> on linux for gcc.

Adding __PCC__ to the macro definition let the code (makedep from Wine) compile:

------ related path of cdefs.h ---------
/* __asm__ ("xyz") is used throughout the headers to rename functions
   at the assembly language level. This is wrapped by the __REDIRECT
   macro, in order to support compilers that can do this some other
   way. When compilers don't support asm-names at all, we have to do
   preprocessor tricks instead (which don't have exactly the right
   semantics, but it's the best we can do).

   Example:
   int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */

#if defined __PCC__ || (defined __GNUC__ && __GNUC__ >= 2)

# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
# ifdef __cplusplus
# define __REDIRECT_NTH(name, proto, alias) \
     name proto __THROW __asm__ (__ASMNAME (#alias))
# else
# define __REDIRECT_NTH(name, proto, alias) \
     name proto __asm__ (__ASMNAME (#alias)) __THROW
# endif
# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
# define __ASMNAME2(prefix, cname) __STRING (prefix) cname

/*
#elif __SOME_OTHER_COMPILER__

# define __REDIRECT(name, proto, alias) name proto; \
_Pragma("let " #name " = " #alias)
*/
#endif
-----------------

Now the linker failed with: __USER_LABEL_PREFIX__fopen64 not found

As a workaround, I added -D__USER_LABEL_PREFIX__="" to CFLAGS in the Makefile.

Now pcc can rebuild makedep and the tool works as expected.

http://wiki.winehq.org/pcc


--
By by ... Detlef


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 25/Aug/09 09:20 PM
Hm, wouldn't it be better to just have __GNUC__ defined? Pcc is pretty close to be compatible with gcc 4.3.1, so hopefully within some weeks that will be added.

Detlef Riekenberg added a comment - 26/Aug/09 12:14 AM - edited
That would be really a good idea, but there are a lot __GNUC__ extensions,
that pcc does not understand. yet.

Some are listed here:
http://pcc.ludd.ltu.se/jira/browse/PCC-18?focusedCommentId=10055&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_10055

Attached is the console output and the logfile for configure Wine with:
CC="pcc -D__GNUC__=4 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1"

Next to the 493 hits of "syntax error" from the cpp regression
( http://pcc.ludd.ltu.se/jira/browse/PCC-88 ) these failures arrived (filtered):
 ac_aggr undefined
 fsblkcnt_t undefined
 fsfilcnt_t undefined
 member 'mt_blksiz' not declared
 mode_t undefined
 no alignment
 pid_t undefined
 request_sense undefined
 ssize_t undefined
 struct or union required
 too few arguments to function
 typeof on undeclared variable
 undefined struct or union (8 hits)
 unknown structure/union/enum (8 hits)
 warning: unsupported attribute 'const' (1 hit)
 warning: unsupported attribute '__const__' (368 hits)
 warning: unsupported attribute '__malloc__' (167 hits)
 warning: unsupported attribute '__mode__' (1063 hits)
 warning: unsupported attribute '__nothrow__' (8750 hits)
 warning: unsupported attribute '__pure__' (297 hits)
 warning: unsupported attribute '__regparm__' (3 hits)
 warning: unsupported attribute '__stdcall__' (1 hit)
 warning: unsupported attribute '__transparent_union__' (1 hit)
 warning: unsupported attribute 'visibility' (1903 hits)
 warning: unsupported attribute '__warn_unused_result__' (12 hits)

__stdcall__ was already reported: http://pcc.ludd.ltu.se/jira/browse/PCC-89

--
By by ... Detlef

Detlef Riekenberg added a comment - 26/Aug/09 12:46 AM
Using pcc with the defines for gcc 2.7.5 or gcc 2.95.3 reduces the needed attributes a bit:
(1 hit) warning: unsupported attribute 'const'
(376) warning: unsupported attribute '__const__'
(1072) warning: unsupported attribute '__mode__'
(3) warning: unsupported attribute '__regparm__'
(1) warning: unsupported attribute '__stdcall__'
(1) warning: unsupported attribute '__transparent_union__'

--
By by ... Detlef


Detlef Riekenberg added a comment - 13/Jun/10 05:06 PM
The missing define for __USER_LABEL_PREFIX is still an issue.
From the gcc manual:

__REGISTER_PREFIX__
    This macro expands to a single token (not a string constant) which is the prefix applied to CPU register names in assembly language for this target. You can use it to write assembly that is usable in multiple environments. For example, in the m68k-aout environment it expands to nothing, but in the m68k-coff environment it expands to a single `%'.
__USER_LABEL_PREFIX__
    This macro expands to a single token which is the prefix applied to user labels (symbols visible to C code) in assembly. For example, in the m68k-aout environment it expands to an `_', but in the m68k-coff environment it expands to nothing.

    This macro will have the correct definition even if -f(no-)underscores is in use, but it will not be correct if target-specific options that adjust this prefix are used (e.g. the OSF/rose -mno-underscores option).

--
By by ... Detlef


Detlef Riekenberg added a comment - 28/Jun/10 07:55 PM
This issue is the current error for building Wine with pcc:

pcc -c -I../../src/tools -I. -I../../src/include -I../include -D__WINESRC__ -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wstrict-prototypes -Wtype-limits -Wwrite-strings -Wpointer-arith -g -O2 -o makedep.o ../../src/tools/makedep.c
pcc -g -O2 -o makedep makedep.o
makedep.o: In function `open_src_file':
../../src/tools/makedep.c:346: undefined reference to `__USER_LABEL_PREFIX__fopen64'

--
By by ... Detlef



Anders Magnusson added a comment - 31/Aug/10 07:29 PM
Added __REGISTER_PREFIX__, __USER_LABEL_PREFIX__ and __OPTIMIZE__.