Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Dec 2015 06:04:10 -0800
From:      Mark Millard <markmi@dsl-only.net>
To:        Andreas Tobler <andreast-list@fgznet.ch>
Cc:        FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org>, freebsd-ports@freebsd.org, Nathan Whitehorn <nwhitehorn@freebsd.org>
Subject:   Re: powerpc64-gcc 5.2 vintages get L". . ." type wrong compared to Char for FreeBSD for lib32 compiling
Message-ID:  <1D7927B2-9CC4-4F43-A6A5-2F2B855CDAE9@dsl-only.net>
In-Reply-To: <5664BA32.3010306@fgznet.ch>
References:  <867D2B14-766D-4104-9A77-C35992C357B8@dsl-only.net> <5664BA32.3010306@fgznet.ch>

next in thread | previous in thread | raw e-mail | index | archive | help
[This time I'm explicit about a patch-gcc-freebsd-powerpc64 update and I =
report that with the change the PowerMac G5 hosted powerpc64-gcc based =
buildworld attempt completed, including WITH_LIB32=3D and WITH_BOOT=3D =
being involved. (But it may not be until tomorrow or later until I test =
if such a build actually works for installworld and reboot.)]

> On 2015-Dec-6, at 2:44 PM, Andreas Tobler <andreast-list@fgznet.ch> =
wrote:
>=20
> On 06.12.15 22:34, Mark Millard wrote:
>> [I picked the lists that I did because powerpc64-gcc is the external
>> toolchain created to allow modern powerpc64 builds.]
>>=20
>> For the powerpc64-gcc 5.2 vintages. . . (using my environment's path
>> as an example)
>>=20
>> =
/usr/obj/portswork/usr/ports/devel/powerpc64-gcc/work/gcc-5.2.0/gcc/config=
/rs6000/freebsd64.h
>> has:
>>=20
>>> /* rs6000.h gets this wrong for FreeBSD.  We use the GCC defaults
>>> instead.  */ #undef WCHAR_TYPE #define WCHAR_TYPE
>>> (TARGET_64BIT ? "int" : "long int") #undef  WCHAR_TYPE_SIZE #define
>>> WCHAR_TYPE_SIZE 32
>>=20
>> That type in quotes ends up being the base type for L". . ."
>> notation, for example. Probably the char notation as well (L'?').
>>=20
>> For FreeBSD Char compatibility in a powerpc64 lib32 context that
>> "long int" should effectively instead be "int", making the
>> conditional above technically unnecessary.
>>=20
>> This blocks compiling lib32 source code that uses such notations as
>> L". . .": "long int" is not compatible with FreeBSD's Char in the
>> powerpc64 environment's 32 bit environment. Some compiler message are
>> explicit about the base types of pointers that result for the
>> mismatches: that is how I know that "long int" is in use for L". . ."
>> and "int" is the other base type involved.
>>=20
>> (Yes, freebsd64.h appears to be used for lib32, at least on
>> powerpc64.  By contrast freebsd.h agrees for the WCHAR_TYPE_SIZE but
>> only undef's WCHAR_TYPE, presuming gcc defaults are correct for
>> FreeBSD as far as the type goes. It might need a more explicit type
>> to be sure of a Char match for that freebsd.h file's context.)
>>=20
>> The 4.9 vintages of powerpc64-gcc were messed up the same way, as was
>> noted at the time.
>=20
> I'll take care.
>=20
> Andreas

(I make no claim that this note manages to preserve tabs and such in the =
diff -u text.)

To turn my earlier note into an actual updated =
devel/powerpc64-gcc/files/patch-gcc-freebsd-powerpc64 instead of the =
more vague words would involve adding what would look something like:

> @@ -304,7 +317,7 @@
> =20
>  /* 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
>=20

(It is what I actually tested.)

The full patch-gcc-freebsd-powerpc64 would then look something like:

> --- gcc/config/rs6000/freebsd64.h.orig  2015-01-05 04:33:28.000000000 =
-0800
> +++ gcc/config/rs6000/freebsd64.h       2015-12-09 00:14:28.520684000 =
-0800
> @@ -65,6 +65,13 @@
>  #define INVALID_64BIT "-m%s not supported in this configuration"
>  #define INVALID_32BIT INVALID_64BIT
> =20
> +/* Use LINUX64 instead of FREEBSD64 for compat with e.g. sysv4le.h */
> +#ifdef LINUX64_DEFAULT_ABI_ELFv2
> +#define ELFv2_ABI_CHECK (rs6000_elf_abi !=3D 1)
> +#else
> +#define ELFv2_ABI_CHECK (rs6000_elf_abi =3D=3D 2)
> +#endif
> +
>  #undef  SUBSUBTARGET_OVERRIDE_OPTIONS
>  #define SUBSUBTARGET_OVERRIDE_OPTIONS                          \
>    do                                                           \
> @@ -84,6 +91,12 @@
>               rs6000_isa_flags &=3D ~OPTION_MASK_RELOCATABLE;     \
>               error (INVALID_64BIT, "relocatable");             \
>             }                                                   \
> +         if (ELFv2_ABI_CHECK)                                  \
> +           {                                                   \
> +             rs6000_current_abi =3D ABI_ELFv2;                   \
> +             if (dot_symbols)                                  \
> +               error ("-mcall-aixdesc incompatible with =
-mabi=3Delfv2"); \
> +           }                                                   \
>           if (rs6000_isa_flags & OPTION_MASK_EABI)              \
>             {                                                   \
>               rs6000_isa_flags &=3D ~OPTION_MASK_EABI;            \
> @@ -304,7 +317,7 @@
> =20
>  /* 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
> =20


I can report that a make buildworld with the following WITH/WITHOUT =
src.conf type options competed based on the rebuilt powerpc64-gcc. =
(WITHOUT_CLANG=3D and WITHOUT_LLDB=3D were just to save time. The =
context is already libc++ based and so WITHOUT_GCC=3D and =
WITHOUT_GNUXX=3D.)

> KERNCONF=3DGENERIC64vtsc-NODEBUG
> TARGET=3Dpowerpc
> TARGET_ARCH=3Dpowerpc64
> WITHOUT_CROSS_COMPILER=3D
> #
> # 1 thing that fails to build if attempted:
> WITHOUT_CLANG_EXTRAS=3D
> #
> WITH_FAST_DEPEND=3D
> WITH_LIBCPLUSPLUS=3D
> WITH_BOOT=3D
> WITH_LIB32=3D
> WITHOUT_CLANG=3D
> WITHOUT_CLANG_IS_CC=3D
> WITHOUT_CLANG_FULL=3D
> WITHOUT_LLDB=3D
> #
> WITHOUT_GCC=3D
> WITHOUT_GNUCXX=3D
> #
> NO_WERROR=3D
> MALLOC_PRODUCTION=3D
> #CFLAGS+=3D -DELF_VERBOSE
> #
> WITH_DEBUG=3D
> WITH_DEBUG_FILES=3D

The FreeBSD version context is:

> # freebsd-version -ku; uname -aKU
> 11.0-CURRENT
> 11.0-CURRENT
> FreeBSD FBSDG5C0 11.0-CURRENT FreeBSD 11.0-CURRENT #17 r291745M: Sat =
Dec  5 08:20:20 PST 2015     =
root@FBSDG5C0:/usr/obj/usr/src/sys/GENERIC64vtsc-NODEBUG  powerpc =
1100091 1100091

The technique of using powerpc64-gcc as the host/cross compiler in this =
context was as follows. (No gcc 4.2.1 present and clang 3.7 unused. No =
initial lib32.)

First some symbolic links:

> # ls -al /usr/lib/libstdc*
> lrwxr-xr-x  1 root  wheel  8 Dec  5 05:41 /usr/lib/libstdc++.a -> =
libc++.a
> lrwxr-xr-x  1 root  wheel  9 Dec  5 05:41 /usr/lib/libstdc++.so -> =
libc++.so

> # ls -l /usr/bin/g[c+][c+]
> lrwxr-xr-x  1 root  wheel  48 Dec  5 05:38 /usr/bin/g++ -> =
/usr/local/bin/powerpc64-portbld-freebsd11.0-g++
> lrwxr-xr-x  1 root  wheel  48 Dec  5 05:38 /usr/bin/gcc -> =
/usr/local/bin/powerpc64-portbld-freebsd11.0-gcc


These cover the existing forced, explicit "gcc" commands in a powerpc64 =
related csu Makefile and other "old style" references that occur.

Also some other file updates:

> # svnlite diff /usr/src/
> Index: /usr/src/sys/boot/ofw/Makefile.inc
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- /usr/src/sys/boot/ofw/Makefile.inc	(revision 291891)
> +++ /usr/src/sys/boot/ofw/Makefile.inc	(working copy)
> @@ -2,7 +2,7 @@
> =20
>  .if ${MACHINE_ARCH} =3D=3D "powerpc64"
>  CFLAGS+=3D	-m32 -mcpu=3Dpowerpc
> -LDFLAGS+=3D	-m elf32ppc_fbsd
> +LDFLAGS+=3D	-Wl,-m -Wl,elf32ppc_fbsd
>  .endif
> =20
>  .include "../Makefile.inc"
> Index: /usr/src/sys/boot/powerpc/Makefile.inc
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- /usr/src/sys/boot/powerpc/Makefile.inc	(revision 291891)
> +++ /usr/src/sys/boot/powerpc/Makefile.inc	(working copy)
> @@ -2,6 +2,7 @@
> =20
>  .if ${MACHINE_ARCH} =3D=3D "powerpc64"
>  CFLAGS+=3D	-m32 -mcpu=3Dpowerpc
> +LDFLAGS+=3D	-Wl,-m -Wl,elf32ppc_fbsd
>  .endif
> =20
>  .include "../Makefile.inc"
> Index: /usr/src/sys/boot/uboot/Makefile.inc
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- /usr/src/sys/boot/uboot/Makefile.inc	(revision 291891)
> +++ /usr/src/sys/boot/uboot/Makefile.inc	(working copy)
> @@ -2,7 +2,7 @@
> =20
>  .if ${MACHINE_ARCH} =3D=3D "powerpc64"
>  CFLAGS+=3D	-m32 -mcpu=3Dpowerpc
> -LDFLAGS+=3D	-m elf32ppc_fbsd
> +LDFLAGS+=3D	-Wl,-m -Wl,elf32ppc_fbsd
>  .endif
> =20
>  .include "../Makefile.inc"

There is more src.conf type content to cause use of the powerpc64-gcc =
toolchain:

> CC=3D/usr/local/bin/powerpc64-portbld-freebsd11.0-gcc
> CXX=3D/usr/local/bin/powerpc64-portbld-freebsd11.0-g++
> CPP=3D/usr/local/bin/powerpc64-portbld-freebsd11.0-cpp
> CROSS_BINUTILS_PREFIX=3D/usr/local/powerpc64-freebsd/bin/
> X_COMPILER_TYPE=3Dgcc
> #
> DEPFLAGS+=3D -isystem =
/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/include/. =
-I/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/include/c+=
+/v1/. -I/usr/include/c++/v1/.
> #
> CFLAGS+=3D -isystem =
/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/include/. =
-Wl,-rpath-link =
-Wl,/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/lib/. =
-Wl,-rpath-link =
-Wl,/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/lib/. =
-L/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/lib/. =
-L/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/lib/.
> #
> LDFLAGS+=3D -Wl,-rpath-link =
-Wl,/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/lib/. =
-Wl,-rpath-link =
-Wl,/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/lib/. =
-L/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/lib/. =
-L/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/lib/.
> #
> CXXFLAGS+=3D -isystem =
/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/include/. =
-I/usr/obj/xtoolchain_noclang/powerpc.powerpc64/usr/src/tmp/usr/include/c+=
+/v1/. -std=3Dgnu++11
> #
> CXXFLAGS+=3D -I/usr/include/c++/v1/. -std=3Dgnu++11 -L/usr/lib/.

(I'll not get into the details of my workaround for building =
powerpc64-gcc in a powerpc64 context, where it is not truly a cross =
compiler. I copy 6 files to the right staging place/name when they are =
not found and then restart the powerpc64-gcc install. I use gcc49 to =
build powerpc64-gcc.)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1D7927B2-9CC4-4F43-A6A5-2F2B855CDAE9>