Bug 205394 - lang/gcc49, lang/gcc5, devel/powerpc64-gcc on powerpc64: lib32's libedit fails to compile, 10 line source shows the problem
Summary: lang/gcc49, lang/gcc5, devel/powerpc64-gcc on powerpc64: lib32's libedit fail...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: powerpc Any
: --- Affects Only Me
Assignee: Andreas Tobler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-18 06:25 UTC by Mark Millard
Modified: 2016-01-10 20:12 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (bapt)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Millard 2015-12-18 06:25:52 UTC
The following simple example shows how/why buildworld for lib32 on powerpc64 fails to compile libedit.

lang/gcc49, lang/gcc5, and devel/powerpc64-gcc all fail to compile the following "main.c" for -m32 on powerpc64.

#include "/usr/include/stddef.h"

const wchar_t* test(const wchar_t* p) { return p; }

int main(void)
{
    const wchar_t* wcpt      = test(L"test");
    const wchar_t  wcarray[] = L"test";
    return 0;
}

For "gcc49 -m32 main.c" the result is:

# gcc49 -m32 main.c
main.c: In function 'main':
main.c:7:37: warning: passing argument 1 of 'test' from incompatible pointer type
     const wchar_t* wcpt      = test(L"test");
                                     ^
main.c:3:16: note: expected 'const wchar_t *' but argument is of type 'long int *'
 const wchar_t* test(const wchar_t* p) { return p; }
                ^
main.c:8:5: error: array of inappropriate type initialized from string constant
     const wchar_t  wcarray[] = L"test";
     ^

gcc5 and powerpc64-gcc get the same.

A possible fix via an addition to lang/gcc5's and devel/powerpc64-gcc's patch-gcc-freebsd-powerpc64 would look like (tabs likely not preserved):

+@@ -304,7 +317,7 @@
+ 
+ /* rs6000.h gets this wrong for FreeBSD.  We use the GCC defaults instead.  */
+ #undef WCHAR_TYPE
+-#define	WCHAR_TYPE      (TARGET_64BIT ? "int" : "long int")
++#define	WCHAR_TYPE      "int"
+ #undef  WCHAR_TYPE_SIZE
+ #define WCHAR_TYPE_SIZE 32
+ 

It appears that lang/gcc49, lang/gcc5-devel, and lang/gcc6-devel do not have a patch-gcc-freebsd-powerpc64 (yet?). Nor lang/gcc48 or older. At least for gcc49 the content of a patch for this issue could be similar from what I can see. I've not looked at the details for the others.

Note: FreeBSD for powerpc64 and its lib32 context define ___wchar_t as int:

# grep wchar_t /usr/include/machine/_types.h                                                                                                                                             typedef	int		___wchar_t;
#define	__WCHAR_MIN	__INT_MIN	/* min value for a wchar_t */
#define	__WCHAR_MAX	__INT_MAX	/* max value for a wchar_t */
Comment 1 Andreas Tobler freebsd_committer 2015-12-19 22:23:07 UTC
This one is fixed upstream. Port fix for gcc-5.3 will follow once I'm ready.
Comment 2 commit-hook freebsd_committer 2016-01-09 11:57:00 UTC
A commit references this bug:

Author: andreast
Date: Sat Jan  9 11:56:21 UTC 2016
New revision: 405619
URL: https://svnweb.freebsd.org/changeset/ports/405619

Log:
  Bring the fixes mentioned below from upstream to our gcc-5.3 release port.

  [1]: https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02057.html
  [2]: https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00685.html

  PR:		205394, 205440
  Approved by:	gerald (maintainer)

Changes:
  head/lang/gcc5/files/patch-gcc-freebsd-powerpc64
Comment 3 Mark Millard 2016-01-10 09:55:52 UTC
devel/powerpc64-gcc that I had listed in the submittal was not updated. Updating /usr/ports to -r405653 and rerunning portmaster -DK devel/powerpc64-gcc still ends up with (found via find . . . -exec grep . . . -print):

#undef WCHAR_TYPE
#define WCHAR_TYPE      (TARGET_64BIT ? "int" : "long int")
#undef  WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 32
/usr/obj/portswork/usr/ports/devel/powerpc64-gcc/work/gcc-5.2.0/gcc/config/rs6000/freebsd64.h

I'm not sure if Bug 205394 should be "unclosed" or if a new bug should be submitted: lang/gcc49 and lang/gcc5 seem to have been updated just fine by their recent updates.
Comment 4 commit-hook freebsd_committer 2016-01-10 20:12:48 UTC
A commit references this bug:

Author: andreast
Date: Sun Jan 10 20:11:52 UTC 2016
New revision: 405744
URL: https://svnweb.freebsd.org/changeset/ports/405744

Log:
  Bring the fixes mentioned below from upstream to our gcc-5.2 powerpc64-gcc
  port.

   [1]: https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02057.html
   [2]: https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00685.html

  PR:		205394, 205440
  Approved by:	bapt (maintainer)

Changes:
  head/devel/powerpc64-gcc/files/patch-gcc-freebsd-powerpc64