powerpc64-gcc 5.2 vintages get L". . ." type wrong compared to Char for FreeBSD for lib32 compiling
Mark Millard
markmi at dsl-only.net
Wed Dec 9 14:04:19 UTC 2015
[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= and WITH_BOOT= 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 at fgznet.ch> wrote:
>
> 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.]
>>
>> For the powerpc64-gcc 5.2 vintages. . . (using my environment's path
>> as an example)
>>
>> /usr/obj/portswork/usr/ports/devel/powerpc64-gcc/work/gcc-5.2.0/gcc/config/rs6000/freebsd64.h
>> has:
>>
>>> /* 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
>>
>> That type in quotes ends up being the base type for L". . ."
>> notation, for example. Probably the char notation as well (L'?').
>>
>> For FreeBSD Char compatibility in a powerpc64 lib32 context that
>> "long int" should effectively instead be "int", making the
>> conditional above technically unnecessary.
>>
>> 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.
>>
>> (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.)
>>
>> The 4.9 vintages of powerpc64-gcc were messed up the same way, as was
>> noted at the time.
>
> I'll take care.
>
> 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 @@
>
> /* 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 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
>
> +/* Use LINUX64 instead of FREEBSD64 for compat with e.g. sysv4le.h */
> +#ifdef LINUX64_DEFAULT_ABI_ELFv2
> +#define ELFv2_ABI_CHECK (rs6000_elf_abi != 1)
> +#else
> +#define ELFv2_ABI_CHECK (rs6000_elf_abi == 2)
> +#endif
> +
> #undef SUBSUBTARGET_OVERRIDE_OPTIONS
> #define SUBSUBTARGET_OVERRIDE_OPTIONS \
> do \
> @@ -84,6 +91,12 @@
> rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
> error (INVALID_64BIT, "relocatable"); \
> } \
> + if (ELFv2_ABI_CHECK) \
> + { \
> + rs6000_current_abi = ABI_ELFv2; \
> + if (dot_symbols) \
> + error ("-mcall-aixdesc incompatible with -mabi=elfv2"); \
> + } \
> if (rs6000_isa_flags & OPTION_MASK_EABI) \
> { \
> rs6000_isa_flags &= ~OPTION_MASK_EABI; \
> @@ -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
>
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= and WITHOUT_LLDB= were just to save time. The context is already libc++ based and so WITHOUT_GCC= and WITHOUT_GNUXX=.)
> KERNCONF=GENERIC64vtsc-NODEBUG
> TARGET=powerpc
> TARGET_ARCH=powerpc64
> WITHOUT_CROSS_COMPILER=
> #
> # 1 thing that fails to build if attempted:
> WITHOUT_CLANG_EXTRAS=
> #
> WITH_FAST_DEPEND=
> WITH_LIBCPLUSPLUS=
> WITH_BOOT=
> WITH_LIB32=
> WITHOUT_CLANG=
> WITHOUT_CLANG_IS_CC=
> WITHOUT_CLANG_FULL=
> WITHOUT_LLDB=
> #
> WITHOUT_GCC=
> WITHOUT_GNUCXX=
> #
> NO_WERROR=
> MALLOC_PRODUCTION=
> #CFLAGS+= -DELF_VERBOSE
> #
> WITH_DEBUG=
> WITH_DEBUG_FILES=
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 at 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
> ===================================================================
> --- /usr/src/sys/boot/ofw/Makefile.inc (revision 291891)
> +++ /usr/src/sys/boot/ofw/Makefile.inc (working copy)
> @@ -2,7 +2,7 @@
>
> .if ${MACHINE_ARCH} == "powerpc64"
> CFLAGS+= -m32 -mcpu=powerpc
> -LDFLAGS+= -m elf32ppc_fbsd
> +LDFLAGS+= -Wl,-m -Wl,elf32ppc_fbsd
> .endif
>
> .include "../Makefile.inc"
> Index: /usr/src/sys/boot/powerpc/Makefile.inc
> ===================================================================
> --- /usr/src/sys/boot/powerpc/Makefile.inc (revision 291891)
> +++ /usr/src/sys/boot/powerpc/Makefile.inc (working copy)
> @@ -2,6 +2,7 @@
>
> .if ${MACHINE_ARCH} == "powerpc64"
> CFLAGS+= -m32 -mcpu=powerpc
> +LDFLAGS+= -Wl,-m -Wl,elf32ppc_fbsd
> .endif
>
> .include "../Makefile.inc"
> Index: /usr/src/sys/boot/uboot/Makefile.inc
> ===================================================================
> --- /usr/src/sys/boot/uboot/Makefile.inc (revision 291891)
> +++ /usr/src/sys/boot/uboot/Makefile.inc (working copy)
> @@ -2,7 +2,7 @@
>
> .if ${MACHINE_ARCH} == "powerpc64"
> CFLAGS+= -m32 -mcpu=powerpc
> -LDFLAGS+= -m elf32ppc_fbsd
> +LDFLAGS+= -Wl,-m -Wl,elf32ppc_fbsd
> .endif
>
> .include "../Makefile.inc"
There is more src.conf type content to cause use of the powerpc64-gcc toolchain:
> CC=/usr/local/bin/powerpc64-portbld-freebsd11.0-gcc
> CXX=/usr/local/bin/powerpc64-portbld-freebsd11.0-g++
> CPP=/usr/local/bin/powerpc64-portbld-freebsd11.0-cpp
> CROSS_BINUTILS_PREFIX=/usr/local/powerpc64-freebsd/bin/
> X_COMPILER_TYPE=gcc
> #
> DEPFLAGS+= -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+= -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+= -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+= -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=gnu++11
> #
> CXXFLAGS+= -I/usr/include/c++/v1/. -std=gnu++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.)
More information about the freebsd-current
mailing list