public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: std::runtime_error on std::locale("")
Date: Sat, 23 Sep 2023 17:23:59 +0900	[thread overview]
Message-ID: <20230923172359.d854a5a98afbc44beaf50c78@nifty.ne.jp> (raw)
In-Reply-To: <87o7huzos2.fsf@Otto.invalid>

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

On Fri, 22 Sep 2023 08:48:45 +0200
ASSI  wrote:
> Takashi Yano via Cygwin writes:
> > I wonder why the following code throws std::runtime_error
> > even though the LC_ALL is set to valid locale other than "C".
> > This does not occur only when LC_ALL is set to "C".
> 
> This functionality is currently only supported for Glibc targets in
> libstdc++.  I seem to remember that I've looked into this some time ago,
> but there didn't seem to be an easy way of enabling it for Cygwin at
> that time.

Thanks for the answer.

It might not be an easy way, but I tried to enabling the locale
feature for libstdc++.

Please try:

1) Run cygport gcc prep
2) Remove libstdc++-v3/config/locale/generic
3) Copy libstdc++-v3/config/locale/gnu to libstdc++-v3/config/locale/generic
4) Apply patches attached to the working source directory.
5) Run cygport gcc compile

I also tried to automate above steps in gcc.cygport.

Further, I tested and confirmed that a few test cases works as expected.

What do you think of this idea?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

[-- Attachment #2: Cygwin-libstdc++-locale.patch --]
[-- Type: text/plain, Size: 10184 bytes --]

diff --git a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c++locale_internal.h b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c++locale_internal.h
index 3ab6af8..81d72f3 100644
--- a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c++locale_internal.h
+++ b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c++locale_internal.h
@@ -41,6 +41,107 @@
 
 #include <ext/concurrence.h>
 
+#ifdef __CYGWIN__
+typedef locale_t __c_locale;
+#define __locale_t locale_t
+#define __nl_langinfo_l nl_langinfo_l
+#define __strcoll_l strcoll_l
+#define __strftime_l strftime_l
+#define __strtod_l strtod_l
+#define __strtof_l strtof_l
+#define __strtold_l strtold_l
+#define __strxfrm_l strxfrm_l
+#define __newlocale newlocale
+#define __freelocale freelocale
+#define __duplocale duplocale
+#define __uselocale uselocale
+#ifdef _GLIBCXX_USE_WCHAR_T
+#define __iswctype_l iswctype_l
+#define __towlower_l towlower_l
+#define __towupper_l towupper_l
+#define __wcscoll_l wcscoll_l
+#define __wcsftime_l wcsftime_l
+#define __wcsxfrm_l wcsxfrm_l
+#define __wctype_l wctype_l
+#endif
+// monetary
+#define __MON_DECIMAL_POINT _NL_MONETARY_MON_DECIMAL_POINT
+#define __MON_THOUSANDS_SEP _NL_MONETARY_MON_THOUSANDS_SEP
+#define __INT_FRAC_DIGITS _NL_MONETARY_INT_FRAC_DIGITS
+#define __MON_GROUPING _NL_MONETARY_MON_GROUPING
+#define __POSITIVE_SIGN _NL_MONETARY_POSITIVE_SIGN
+#define __NEGATIVE_SIGN _NL_MONETARY_NEGATIVE_SIGN
+#define __INT_CURR_SYMBOL _NL_MONETARY_INT_CURR_SYMBOL
+#define __INT_P_SIGN_POSN _NL_MONETARY_INT_P_SIGN_POSN
+#define __INT_N_SIGN_POSN _NL_MONETARY_INT_N_SIGN_POSN
+#define __INT_P_CS_PRECEDES _NL_MONETARY_INT_P_CS_PRECEDES
+#define __INT_N_CS_PRECEDES _NL_MONETARY_INT_N_CS_PRECEDES
+#define __INT_P_SEP_BY_SPACE _NL_MONETARY_INT_P_SEP_BY_SPACE
+#define __INT_N_SEP_BY_SPACE _NL_MONETARY_INT_N_SEP_BY_SPACE
+#define __CURRENCY_SYMBOL _NL_MONETARY_CURRENCY_SYMBOL
+#define __P_SIGN_POSN _NL_MONETARY_P_SIGN_POSN
+#define __N_SIGN_POSN _NL_MONETARY_N_SIGN_POSN
+#define __P_CS_PRECEDES _NL_MONETARY_P_CS_PRECEDES
+#define __N_CS_PRECEDES _NL_MONETARY_N_CS_PRECEDES
+#define __P_SEP_BY_SPACE _NL_MONETARY_P_SEP_BY_SPACE
+#define __N_SEP_BY_SPACE _NL_MONETARY_N_SEP_BY_SPACE
+#define __FRAC_DIGITS _NL_MONETARY_FRAC_DIGITS
+#define _NL_MONETARY_DECIMAL_POINT_WC _NL_MONETARY_WMON_DECIMAL_POINT
+#define _NL_MONETARY_THOUSANDS_SEP_WC _NL_MONETARY_WMON_THOUSANDS_SEP
+// numeric
+#define DECIMAL_POINT _NL_MONETARY_MON_DECIMAL_POINT // No other appropriate ones.
+#define THOUSANDS_SEP _NL_MONETARY_MON_THOUSANDS_SEP // No other appropriate ones.
+#define GROUPING _NL_NUMERIC_GROUPING
+// time
+#define _NL_WD_FMT _NL_TIME_WD_FMT
+#define _NL_WD_T_FMT _NL_TIME_WD_T_FMT
+#define _NL_WT_FMT _NL_TIME_WT_FMT
+#define _NL_WERA_D_FMT _NL_TIME_WERA_D_FMT
+#define _NL_WERA_D_T_FMT _NL_TIME_WERA_D_T_FMT
+#define _NL_WERA_T_FMT _NL_TIME_WERA_T_FMT
+#define _NL_WAM_STR _NL_TIME_WAM_STR
+#define _NL_WPM_STR _NL_TIME_WPM_STR
+#define _NL_WT_FMT_AMPM _NL_TIME_WT_FMT_AMPM
+#define _NL_WDAY_1 _NL_TIME_WWEEKDAY_1
+#define _NL_WDAY_2 _NL_TIME_WWEEKDAY_2
+#define _NL_WDAY_3 _NL_TIME_WWEEKDAY_3
+#define _NL_WDAY_4 _NL_TIME_WWEEKDAY_4
+#define _NL_WDAY_5 _NL_TIME_WWEEKDAY_5
+#define _NL_WDAY_6 _NL_TIME_WWEEKDAY_6
+#define _NL_WDAY_7 _NL_TIME_WWEEKDAY_7
+#define _NL_WABDAY_1 _NL_TIME_WWDAY_1
+#define _NL_WABDAY_2 _NL_TIME_WWDAY_2
+#define _NL_WABDAY_3 _NL_TIME_WWDAY_3
+#define _NL_WABDAY_4 _NL_TIME_WWDAY_4
+#define _NL_WABDAY_5 _NL_TIME_WWDAY_5
+#define _NL_WABDAY_6 _NL_TIME_WWDAY_6
+#define _NL_WABDAY_7 _NL_TIME_WWDAY_7
+#define _NL_WMON_1 _NL_TIME_WMONTH_1
+#define _NL_WMON_2 _NL_TIME_WMONTH_2
+#define _NL_WMON_3 _NL_TIME_WMONTH_3
+#define _NL_WMON_4 _NL_TIME_WMONTH_4
+#define _NL_WMON_5 _NL_TIME_WMONTH_5
+#define _NL_WMON_6 _NL_TIME_WMONTH_6
+#define _NL_WMON_7 _NL_TIME_WMONTH_7
+#define _NL_WMON_8 _NL_TIME_WMONTH_8
+#define _NL_WMON_9 _NL_TIME_WMONTH_9
+#define _NL_WMON_10 _NL_TIME_WMONTH_10
+#define _NL_WMON_11 _NL_TIME_WMONTH_11
+#define _NL_WMON_12 _NL_TIME_WMONTH_12
+#define _NL_WABMON_1 _NL_TIME_WMON_1
+#define _NL_WABMON_2 _NL_TIME_WMON_2
+#define _NL_WABMON_3 _NL_TIME_WMON_3
+#define _NL_WABMON_4 _NL_TIME_WMON_4
+#define _NL_WABMON_5 _NL_TIME_WMON_5
+#define _NL_WABMON_6 _NL_TIME_WMON_6
+#define _NL_WABMON_7 _NL_TIME_WMON_7
+#define _NL_WABMON_8 _NL_TIME_WMON_8
+#define _NL_WABMON_9 _NL_TIME_WMON_9
+#define _NL_WABMON_10 _NL_TIME_WMON_10
+#define _NL_WABMON_11 _NL_TIME_WMON_11
+#define _NL_WABMON_12 _NL_TIME_WMON_12
+#else // __CYGWIN__
+
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
 
 extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
@@ -67,6 +168,8 @@ extern "C" __typeof(wctype_l) __wctype_l;
 
 #endif // GLIBC 2.3 and later
 
+#endif // __CYGWIN__
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
diff --git a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c_locale.cc b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c_locale.cc
index 45437e7..177882c 100644
--- a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c_locale.cc
+++ b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c_locale.cc
@@ -28,6 +28,9 @@
 
 // Written by Benjamin Kosnik <bkoz@redhat.com>
 
+#ifdef __CYGWIN__
+#define _GNU_SOURCE 1
+#endif
 #include <locale>
 #include <stdexcept>
 #include <limits>
diff --git a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c_locale.h b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c_locale.h
index bc24355..6f13e06 100644
--- a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c_locale.h
+++ b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/c_locale.h
@@ -49,7 +49,11 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#ifdef __CYGWIN__
+#define __uselocale uselocale
+#else
   extern "C" __typeof(uselocale) __uselocale;
+#endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
@@ -59,7 +63,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#ifdef __CYGWIN__
+  typedef locale_t		__c_locale;
+#else
   typedef __locale_t		__c_locale;
+#endif
 
   // Convert numeric value of type double and long double to string and
   // return length of string.  If vsnprintf is available use it, otherwise
diff --git a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/ctype_members.cc b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/ctype_members.cc
index e7a66f1..ee3c236 100644
--- a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/ctype_members.cc
+++ b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/ctype_members.cc
@@ -32,6 +32,15 @@
 #include <cstdio>
 #include <bits/c++locale_internal.h>
 
+#ifdef __CYGWIN__
+# include <endian.h>
+# if __BYTE_ORDER == __BIG_ENDIAN
+#  define _ISbit(bit)        (1 << (bit))
+# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
+#  define _ISbit(bit)        ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
+# endif
+#endif
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -45,9 +54,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	this->_S_destroy_c_locale(this->_M_c_locale_ctype);
 	this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
+#ifndef __CYGWIN__
 	this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
 	this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
 	this->_M_table = this->_M_c_locale_ctype->__ctype_b;
+#endif
       }
   }
 
@@ -94,9 +105,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       case graph:
 	__ret = __wctype_l("graph", _M_c_locale_ctype);
 	break;
+#ifndef __CYGWIN__
       case blank:
 	__ret = __wctype_l("blank", _M_c_locale_ctype);
 	break;
+#endif
       default:
 	__ret = __wmask_type();
       }
diff --git a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/monetary_members.cc b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/monetary_members.cc
index 0b7e0ec..05c4161 100644
--- a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/monetary_members.cc
+++ b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/monetary_members.cc
@@ -596,12 +596,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  setlocale(LC_ALL, __name);
 #endif
 
+#ifdef __CYGWIN__
+	  union { char *__s; wchar_t *__w; } __u;
+	  __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
+	  _M_data->_M_decimal_point = *__u.__w;
+
+	  __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
+	  _M_data->_M_thousands_sep = *__u.__w;
+#else
 	  union { char *__s; wchar_t __w; } __u;
 	  __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
 	  _M_data->_M_decimal_point = __u.__w;
 
 	  __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
 	  _M_data->_M_thousands_sep = __u.__w;
+#endif
 
 	  // Check for NULL, which implies no fractional digits.
 	  if (_M_data->_M_decimal_point == L'\0')
diff --git a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/numeric_members.cc b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/numeric_members.cc
index 19bf7d1..a793140 100644
--- a/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/numeric_members.cc
+++ b/src/gcc-11.4.0/libstdc++-v3/config/locale/generic/numeric_members.cc
@@ -206,6 +206,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
 	{
 	  // Named locale.
+#ifdef __CYGWIN__
+	  union { char *__s; wchar_t *__w; } __u;
+	  __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
+	  _M_data->_M_decimal_point = *__u.__w;
+
+	  __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
+	  _M_data->_M_thousands_sep = *__u.__w;
+#else
 	  // NB: In the GNU model wchar_t is always 32 bit wide.
 	  union { char *__s; wchar_t __w; } __u;
 	  __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
@@ -213,6 +221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 	  __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
 	  _M_data->_M_thousands_sep = __u.__w;
+#endif
 
 	  // Check for NULL, which implies no grouping.
 	  if (_M_data->_M_thousands_sep == L'\0')

[-- Attachment #3: gcc.cygport --]
[-- Type: text/plain, Size: 16153 bytes --]

# -*- mode: sh; sh-shell: bash -*-
BUILD_REQUIRES=""
################################################################################
#
# Cygport control script for gcc.
#
# Copyright (C) 2008, 2009, 2010 Dave Korn
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this script.  If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
TOOLCHAIN_TARGET="native"
inherit toolchain python3

NAME="gcc"
VERSION="11.4.0"
RELEASE="1"
CATEGORY="Devel"
SUMMARY="GNU Compiler Collection"
DESCRIPTION="The GNU Compiler Collection includes front ends for C, C++,
Objective-C, Fortran, and Go, as well as libraries for these
languages (libstdc++, libgcj,...)."
HOMEPAGE="https://gcc.gnu.org/"
LICENSE="GPL-3.0-or-later"
GFMABI="15"
PVmaj=${PV%%.*}
case ${PV} in
    *+20[1-9][0-9][0-1][0-9][0-3][0-9]) # snapshot
	SD=${PV##*+}
	SRC_URI="  mirror://gcc/snapshots/${PVmaj}-${SD}/gcc-${PVmaj}-${SD}.tar.xz"
	SRC_URI+=" mirror://gcc/snapshots/${PVmaj}-${SD}/sha512.sum#/gcc-${PVmaj}-${SD}.tar.xz.sha512"
	SRC_DIR="gcc-${PVmaj}-${SD}"
	;;
    *)                                  # release
	SRC_URI="  mirror://gnu/gcc/gcc-${PV}/gcc-${PV}.tar.xz"
	SRC_URI+=" mirror://gnu/gcc/gcc-${PV}/gcc-${PV}.tar.xz.sig"
	SRC_DIR="gcc-${PV}"
	;;
esac
SRC_URI+=" Cygwin-libstdc++-locale.patch"
# patches re-created in cygwin-gcc git branch cygwin-11.3.1
PATCH_URI="
  0001-Cygwin-use-SysV-ABI-on-x86_64.patch
  0002-Cygwin-add-dummy-pthread-tsaware-and-large-address-a.patch
  0003-Cygwin-handle-dllimport-properly-in-medium-model-V2.patch
  0004-Cygwin-MinGW-skip-test.patch
  0005-Cygwin-define-RTS_CONTROL_ENABLE-and-DTR_CONTROL_ENA.patch
  0007-Cygwin-__cxa-atexit.patch
  0008-Cygwin-libgomp-soname.patch
  0009-Cygwin-g-time.patch
  0010-Cygwin-newlib-ftm.patch
  0011-Cygwin-define-STD_UNIX.patch
"
# already fixed in snapshot
#  0006-Cygwin-fix-some-implicit-declaration-warnings-and-re.patch
#DISABLE_BOOTSTRAP=1
defined DISABLE_BOOTSTRAP &&
    inform "Disable Bootstrapping."
LIBGCCJIT=1
if defined DISABLE_LIBGCCJIT
then
    inform "Support for libgccjit disabled."
else
    PATCH_URI+="
      0101-Cygwin-enable-libgccjit-not-just-for-MingW.patch
      0102-Cygwin-testsuite-fixes-for-libgccjit.patch
    "
    inform "Support for libgccjit enabled."
fi
# Ada
PATCH_URI+="
  0201-Cygwin-ada-shared-prefix.patch
"

# CI hints
SCALLYWAG="nobuild notest nodeploy"

# new files created by patches, need to be removed if re-prep'ing
DISTCLEANFILES="config/mt-cygwin gcc/ada/system-cygwin-x86_64.ads libgomp/config/cygwin/plugin-suffix.h"

# These must not be set in the environment, but main cygport
# script tries to be too helpful here and confuses auto-detection
# process during gcc build stages.
unset CC CXX F77 FC GCJ GOC OBJC OBJCXX FCFLAGS FFLAGS CFLAGS CXXFLAGS

CYGPORT_USE_UNSTABLE_API=1
src_unpack_hook() {
        chmod a+x gcc/testsuite/ada/acats/run_test.exp
}

# gccgo: requires <ucontext.h>
# libexecdir: http://cygwin.com/ml/cygwin/2013-11/msg00018.html et al
# libssp: conflicts with builtin SSP
CYGCONF_ARGS="
    --libexecdir=/usr/lib
    --with-gcc-major-version-only
    --enable-shared --enable-shared-libgcc --enable-static
    --enable-version-specific-runtime-libs
    $(cross_compiling || echo --enable-bootstrap)
    --enable-__cxa_atexit
    --with-dwarf2
    ${ARCH_i686+--with-arch=i686} --with-tune=generic
    ${ARCH_i686+--disable-sjlj-exceptions}
    ${DISABLE_BOOTSTRAP+--disable-bootstrap}
    --enable-languages=ada,c,c++,d,fortran,lto,objc,obj-c++${LIBGCCJIT+,jit}
    --enable-graphite
    --enable-threads=posix
    --enable-libatomic
    --enable-libgomp
    --enable-libquadmath
    --enable-libquadmath-support
    --disable-libssp
    --enable-libada
    --disable-symvers
    --disable-multilib
    --with-gnu-ld --with-gnu-as
    --with-cloog-include=$(${TOOLCHAIN_TARGET}-gcc -print-sysroot)/usr/include/cloog-isl
    --without-libiconv-prefix
    --without-libintl-prefix
    --with-system-zlib
    --enable-linker-build-id
    --with-default-libstdcxx-abi=gcc4-compatible
    --enable-libstdcxx-filesystem-ts
"

MAKEOPTS+=" -Otarget"

src_compile() {
    # Enable c++ locale features for not just "C" locale.
    cd ${S}
    rm -r libstdc++-v3/config/locale/generic
    cp -r libstdc++-v3/config/locale/gnu libstdc++-v3/config/locale/generic
    patch -p 3 < Cygwin-libstdc++-locale.patch

    cd ${B}
    # use built-in SSP with Cygwin 2.10
    # FIXME: --disable-libssp should suffice in GCC 8
    # export gcc_cv_libc_provides_ssp=yes
    # configure tries to test SUSv4-compliant behaviour of
    # realpath(..., NULL) via _XOPEN_VERSION
    export glibcxx_cv_realpath=yes

    ___CFLAGS=`echo ${CFLAGS} | sed s/-Werror=format-security/-Wformat-security/g`
    ___CFLAGS=`echo ${___CFLAGS} | sed s/\(-Wp,\)\?-D_FORTIFY_SOURCE=[12]//g`
    ___CFLAGS=`echo ${___CFLAGS} | sed 's/[[:blank:]]\+/ /g'`

    ___CXXFLAGS=`echo ${CXXFLAGS} | sed s/-Werror=format-security/-Wformat-security/g`
    ___CXXFLAGS=`echo ${___CXXFLAGS} | sed s/\(-Wp,\)\?-D_FORTIFY_SOURCE=[12]//g`
    ___CXXFLAGS=`echo ${___CXXFLAGS} | sed 's/[[:blank:]]\+/ /g'`

    export CFLAGS=${___CFLAGS}
    export CXXFLAGS=${___CXXFLAGS}
    # MingW64 header clash
    export CPPFLAGS+=" -DWIN32_LEAN_AND_MEAN"
    # parallel make encounters problems frequently
    defined CYGPORT_RECOMPILE && echo recompile only ||
            cygconf # CYGCONF_ARGS defined above
    # make hangs after finishing everything on x86_64?
    #cygmake BOOT_CFLAGS="${CXXFLAGS}"
    make ${MAKEOPTS} BOOT_CFLAGS="${CXXFLAGS}" || true
}

# override default src_test, as we need to ignore failures and
# add build subdirectories to path so DLLs can definitely be found.
src_test() {
    local gccpath

    gccpath="${B}/gcc/ada/rts:"
    gccpath+="${B}/${TOOLCHAIN_TARGET}/libgcc/shlib:"
    gccpath+="${B}/${TOOLCHAIN_TARGET}/libatomic/.libs:"
    gccpath+="${B}/${TOOLCHAIN_TARGET}/libgfortran/.libs:"
    gccpath+="${B}/${TOOLCHAIN_TARGET}/libgomp/.libs:"
    gccpath+="${B}/${TOOLCHAIN_TARGET}/libobjc/.libs:"
    gccpath+="${B}/${TOOLCHAIN_TARGET}/libquadmath/.libs:"
    gccpath+="${B}/${TOOLCHAIN_TARGET}/libstdc++-v3/src/.libs:"

    cd ${B}
    # cygtest doesn't work since btest_gnudebuglink has no creation rule
    [ "no" != "${CYGPORT_RUN_UNSTABLE_TESTS-no}" ] &&
        PATH="${gccpath}${PATH}" make ${MAKEOPTS} -k check ||
	    echo "Unstable test, set CYGPORT_RUN_UNSTABLE_TESTS to run."
}

src_install() {
    cd ${B}
    # Appears to be a problem with parallel install; finclude/ dir
    # ends up empty somehow.
    cyginstall -j1

    # Workaround GCC install bug
    if defined ARCH_x86_64
    then
        mv ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/lib/libgcc_s.dll.a ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/
        #mv ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/lib32/libgcc_s.dll.a ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/32/
    fi

    # Move GDB auto-load to correct name and location
    dodir /usr/share/gdb/auto-load/usr/bin
    sed -i -e "/^libdir/ s|/lib/gcc/.*|/bin'|" \
        ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libstdc++.dll.a-gdb.py
    mv ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libstdc++.dll.a-gdb.py \
       ${D}/usr/share/gdb/auto-load/usr/bin/cygstdc++-6.dll-gdb.py
    python_optimize /usr/share/gcc-${PVmaj}/python

    # Move ADA DLLs
    mv -v ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/adalib/cyggna*.dll ${D}/usr/bin/
    # rename libgna cyggna ${D}/usr/bin/libgna*.dll

    # Now move docs to correct location
    mkdir -p ${D}/usr/share/doc/${PN}
    tar -cj -C ${S} INSTALL | tar -xj -C ${D}/usr/share/doc/${PN}/

    # create standard aliases
    dosym gcc.exe /usr/bin/cc
    dosym ../bin/cpp.exe /usr/lib/cpp
    dosym gfortran.exe /usr/bin/f95

    cat > ${D}/usr/bin/c89 <<_EOF
#!/bin/sh
fl="-std=c89"
for opt; do
  case "\$opt" in
    -ansi|-std=c89|-std=iso9899:1990) fl="";;
    -std=*) echo "`basename \$0` called with non ANSI/ISO C option \$opt" >&2
            exit 1;;
  esac
done
exec /usr/bin/gcc \$fl \${1+"\$@"}
_EOF

    cat > ${D}/usr/bin/c99 <<_EOF
#!/bin/sh
fl="-std=c99"
for opt; do
  case "\$opt" in
    -std=c99|-std=iso9899:1999) fl="";;
    -std=*) echo "`basename \$0` called with non ISO C99 option \$opt" >&2
            exit 1;;
  esac
done
exec /usr/bin/gcc \$fl \${1+"\$@"}
_EOF
    chmod 755 ${D}/usr/bin/c?9

    # clean-up include-fixed
    mv ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include-fixed/*limits.h \
       ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include/
    rm -fr ${D}/usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include-fixed/
}

KEEP_LA_FILES="none"

PKG_NAMES="${PN}-ada ${PN}-core ${PN}-g++ ${PN}-gdc ${PN}-fortran ${PN}-objc ${PN}-objc++"
PKG_NAMES+=" libatomic1 libgcc1 libgfortran5 libgomp1 libgnat11 libobjc4 libstdc++6 libquadmath0"
defined LIBGCCJIT &&
    PKG_NAMES+=" libgccjit0"
gcc_REQUIRES="${PN}${PVmaj} ${PN}-g++"
gcc_ada_SUMMARY="${SUMMARY} (Ada)"
gcc_ada_REQUIRES="${PN}${PVmaj}"
gcc_ada_CONTENTS="
    usr/bin/gnat*.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/ada_target_properties
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/adainclude
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/adalib
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/gnat1.exe
    usr/share/info/gnat-style.info*
    usr/share/info/gnat_rm.info*
    usr/share/info/gnat_ugn.info*
"
gcc_core_SUMMARY="${SUMMARY} (C, OpenMP)"
gcc_core_REQUIRES="binutils cygwin-devel w32api-headers w32api-runtime windows-default-manifest"
gcc_core_OBSOLETES="${PN}-ada ${PN}-cilkplus"
gcc_core_PROVIDES="${PN}${PVmaj}"
gcc_core_CONTENTS="
    --exclude=jni*.h
    usr/bin/cc
    usr/bin/c89
    usr/bin/c99
    usr/bin/cpp.exe
    usr/bin/gcc.exe
    usr/bin/gcc-ar.exe
    usr/bin/gcc-nm.exe
    usr/bin/gcc-ranlib.exe
    usr/bin/gcov.exe
    usr/bin/gcov-tool.exe
    usr/bin/gcov-dump.exe
    usr/bin/lto-dump.exe
    usr/bin/${TOOLCHAIN_TARGET}-gcc-${PVmaj}.exe
    usr/bin/${TOOLCHAIN_TARGET}-gcc.exe
    usr/bin/${TOOLCHAIN_TARGET}-gcc-ar.exe
    usr/bin/${TOOLCHAIN_TARGET}-gcc-nm.exe
    usr/bin/${TOOLCHAIN_TARGET}-gcc-ranlib.exe
    usr/lib/cpp
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include/*.h
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/install-tools
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cc1.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/collect2.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/crt*.o
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cyglto_plugin.dll
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libatomic.*
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libgcc*
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libgcov.*
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libgomp.*
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libquadmath.*
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/lto*.exe
    usr/share/doc/${PN}/
    usr/share/info/cpp.info*
    usr/share/info/cppinternals.info*
    usr/share/info/gcc.info*
    usr/share/info/gccinstall.info*
    usr/share/info/gccint.info*
    usr/share/info/libgomp.info*
    usr/share/info/libquadmath.info*
    usr/share/locale/*
    usr/share/man/man1/cpp.1*
    usr/share/man/man1/gcc.1*
    usr/share/man/man1/gcov.1*
    usr/share/man/man1/gcov-dump.1.*
    usr/share/man/man1/gcov-tool.1.*
    usr/share/man/man1/lto-dump.1.*
    usr/share/man/man7/fsf-funding.7*
    usr/share/man/man7/gfdl.7*
    usr/share/man/man7/gpl.7*
"
gcc_g___SUMMARY="${SUMMARY} (C++)"
gcc_g___REQUIRES="${PN}${PVmaj}"
gcc_g___CONTENTS="
    --exclude=gnu
    usr/bin/c++.exe
    usr/bin/g++.exe
    usr/bin/${TOOLCHAIN_TARGET}-c++.exe
    usr/bin/${TOOLCHAIN_TARGET}-g++.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cc1plus.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/g++-mapper-server.exe*
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include/c++
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libstdc++*
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libsupc++*
    usr/share/man/man1/g++.1*
"
gcc_gdc_SUMMARY="${SUMMARY} (D)"
gcc_gdc_REQUIRES="${PN}${PVmaj}"
gcc_gdc_CONTENTS="
    --exclude=gnu
    usr/bin/gdc.exe
    usr/bin/${TOOLCHAIN_TARGET}-gdc.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/d21.exe
    usr/share/info/gdc.info*
    usr/share/man/man1/gdc.1*
"
gcc_fortran_SUMMARY="${SUMMARY} (Fortran)"
gcc_fortran_REQUIRES="${PN}${PVmaj}"
gcc_fortran_PROVIDES="gfm${GFMABI}" # GNU Fortran Module version
gcc_fortran_CONTENTS="
    usr/bin/f95
    usr/bin/gfortran.exe
    usr/bin/${TOOLCHAIN_TARGET}-gfortran.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/finclude/
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/f951.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libcaf_single.a
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libgfortran*
    usr/share/info/gfortran.info*
    usr/share/man/man1/gfortran.1*
"
gcc_objc_SUMMARY="${SUMMARY} (Objective-C)"
gcc_objc_REQUIRES="${PN}${PVmaj}"
gcc_objc_CONTENTS="
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/include/objc/
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cc1obj.exe
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/libobjc.*
"
gcc_objc___SUMMARY="${SUMMARY} (Objective-C++)"
gcc_objc___REQUIRES="${PN}${PVmaj} ${PN}-g++ ${PN}-objc"
gcc_objc___CONTENTS="
    usr/lib/gcc/${TOOLCHAIN_TARGET}/${PVmaj}/cc1objplus.exe
"
libatomic1_CATEGORY="Libs"
libatomic1_SUMMARY="GCC C11/C++11 locked atomics runtime library"
libatomic1_CONTENTS="usr/bin/cygatomic-1.dll"
libgcc1_CATEGORY="Libs"
libgcc1_SUMMARY="GCC C runtime library"
libgcc1_CONTENTS="usr/bin/cyggcc_s${ARCH_x86_64+-seh}-1.dll"
libgfortran5_CATEGORY="Libs"
libgfortran5_SUMMARY="GCC Fortran runtime library"
libgfortran5_CONTENTS="usr/bin/cyggfortran-5.dll"
libgnat11_CATEGORY="Libs"
libgnat11_SUMMARY="GCC Ada runtime library"
libgnat11_CONTENTS="usr/bin/cyggnarl-11.dll usr/bin/cyggnat-11.dll"
libgomp1_CATEGORY="Libs"
libgomp1_SUMMARY="GCC OpenMP runtime library"
libgomp1_CONTENTS="usr/bin/cyggomp-1.dll"
libobjc4_CATEGORY="Libs"
libobjc4_SUMMARY="GCC Objective-C runtime library"
libobjc4_CONTENTS="usr/bin/cygobjc-4.dll"
libstdc__6_CATEGORY="Libs"
libstdc__6_SUMMARY="GCC C++ runtime library"
libstdc__6_CONTENTS="usr/bin/cygstdc++-6.dll"
libstdc__devel_CATEGORY="_obsolete"
libstdc__devel_SUMMARY="Obsolete package"
libquadmath0_CATEGORY="Libs"
libquadmath0_SUMMARY="GCC Quad-Precision Math runtime library"
libquadmath0_CONTENTS="usr/bin/cygquadmath-0.dll"
libvtv0_CATEGORY="Libs"
libvtv0_SUMMARY="GCC vtable verification library"
libvtv0_CONTENTS="usr/bin/cygvtv-0.dll usr/bin/cygvtv_stubs-0.dll"
gcc_debuginfo_CONTENTS+=" usr/share/gcc-${PVmaj}/python/libstdcxx/"
if defined LIBGCCJIT
then
    inform "Package libgccjit0 will be provided."
    libgccjit0_CATEGORY="Libs"
    libgccjit0_SUMMARY="GCC JIT runtime library, header files and documentation"
    libgccjit0_CONTENTS="
        usr/bin/cyggccjit-0.dll
        usr/include/libgccjit*
        usr/lib/libgccjit.dll.a
        usr/share/info/libgccjit.info.gz
"
    libgccjit0_REQUIRES="gcc-core"
fi

DIFF_EXCLUDES="
    c_locale.cc
    c_locale.h
    c++locale_internal.h
    codecvt_members.cc
    collate_members.cc
    ctype_members.cc
    messages_members.cc
    messages_members.h
    monetary_members.cc
    numeric_members.cc
    time_members.cc
    time_members.h
"

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: gcc-11.4.0.src.patch --]
[-- Type: text/poain; name="gcc-11.4.0.src.patch", Size: 659 bytes --]

diff --git a/src/gcc-11.4.0/libstdc++-v3/src/Makefile.in b/src/gcc-11.4.0/libstdc++-v3/src/Makefile.in
index 2fff462..7cef94d 100644
--- a/src/gcc-11.4.0/libstdc++-v3/src/Makefile.in
+++ b/src/gcc-11.4.0/libstdc++-v3/src/Makefile.in
@@ -535,7 +535,7 @@ libstdc___la_DEPENDENCIES = \
 	$(top_builddir)/src/c++20/libc++20convenience.la
 
 libstdc___la_LDFLAGS = \
-	-version-info $(libtool_VERSION) ${version_arg} -lm
+	-version-info $(libtool_VERSION) ${version_arg} -lm -lintl
 
 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
 @GLIBCXX_LDBL_ALT128_COMPAT_FALSE@@GLIBCXX_LDBL_COMPAT_TRUE@LTCXXCOMPILE64 = $(LTCXXCOMPILE)

  reply	other threads:[~2023-09-23  8:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 16:12 Takashi Yano
2023-09-21 16:28 ` Takashi Yano
2023-09-21 18:08   ` Brian Inglis
2023-09-21 19:06     ` Christian Franke
2023-09-22  4:08       ` Takashi Yano
2023-09-22  7:20         ` Christian Franke
2023-09-22  5:56       ` Martin Wege
2023-09-22 12:01         ` Brian Inglis
2023-09-22  6:48 ` ASSI
2023-09-23  8:23   ` Takashi Yano [this message]
2023-09-23  8:42     ` Takashi Yano
2023-09-27 10:50     ` Takashi Yano
2023-12-31  6:57       ` Takashi Yano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230923172359.d854a5a98afbc44beaf50c78@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).