aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/configure.ac
AgeCommit message (Collapse)AuthorFilesLines
2024-08-28libstdc++: Fix autoconf check for O_NONBLOCK in <fcntl.h>Jonathan Wakely1-1/+4
I misused the AC_CHECK_DECL macro, assuming that it behaved like AC_CHECK_DECLS and always defined a HAVE_xxx macro if the decl was found. Instead, the [action-if-found] shell commands are needed to defined HAVE_O_NONBLOCK explicitly. libstdc++-v3/ChangeLog: * configure.ac: Fix check for O_NONBLOCK. * config.h.in: Regenerate. * configure: Regenerate.
2024-08-16libstdc++-v3: Handle iconv as optional for newlib builds [PR116362]Hans-Peter Nilsson1-1/+9
Support for iconv in newlib seems to have been always assumed present by libstdc++-v3, but is default off. Though, it hasn't been used before recent libstdc++ changes that actually call iconv functions. This now leads to failures exposed by running the test-suite, unless the newlib being used has been explicitly configured with --enable-newlib-iconv. When failing, there are undefined references to iconv, iconv_open or iconv_close for multiple tests. Thankfully there's a macro in newlib.h that we can check to detect presence of iconv support for the newlib build that's used. libstdc++-v3: PR libstdc++/116362 * configure.ac: Check newlib configuration whether iconv is enabled. * configure: Regenerate.
2024-05-30[libstdc++-v3] [rtems] enable filesystem supportAlexandre Oliva1-0/+7
mkdir, chdir and chmod functions are defined in librtemscpu, that doesn't get linked in during libstdc++-v3 configure, but applications use -qrtems for linking, which brings those symbols in, so it makes sense to mark them as available so that the C++ filesystem APIs are enabled. for libstdc++-v3/ChangeLog * configure.ac [*-*-rtems*]: Set chdir, chmod and mkdir as available. * configure: Rebuilt.
2024-02-19libstdc++, Darwin: Handle a linker warning [PR112397].Iain Sandoe1-0/+6
Darwin's linker warns when we make a direct branch to code that is in a weak definition (citing that if a different implementation of the weak function is chosen by the dynamic linker this would be an error). As the analysis in the PR shows, this can happen when we have hot/ cold partitioning and there is an error path that is primarily cold but makes use of epilogue code in the hot section. In this simple case, we can easily deduce that the code is in fact safe; however that is not something we can realistically implement in the linker. Since the user-replaceable allocators are implemented using weak definitions, this is a warning that is frequently flagged up in both the testsuite and end-user code. The chosen solution here is to suppress the hot/cold partitioning for these cases (it is unlikely to impact performance much c.f. the actual allocation). PR target/112397 libstdc++-v3/ChangeLog: * configure: Regenerate. * configure.ac: Detect if we are building for Darwin. * libsupc++/Makefile.am: If we are building for Darwin, then suppress hot/cold partitioning for the array allocators. * libsupc++/Makefile.in: Regenerated. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-17libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318]Jonathan Wakely1-0/+3
This is another C++26 change, approved in Varna 2023. We require a new static array of data that is extracted from the IANA Character Sets database. A new Python script to generate a header from the IANA CSV file is added. The text_encoding class is basically just a pointer to an {ID,name} pair in the static array. The aliases view is also just the same pointer (or empty), and the view's iterator moves forwards and backwards in the array while the array elements have the same ID (or to one element further, for a past-the-end iterator). Because those iterators refer to a global array that never goes out of scope, there's no reason they should every produce undefined behaviour or indeterminate values. They should either have well-defined behaviour, or abort. The overhead of ensuring those properties is pretty low, so seems worth it. This means that an aliases_view iterator should never be able to access out-of-bounds. A non-value-initialized iterator always points to an element of the static array even when not dereferenceable (the array has unreachable entries at the start and end, which means that even a past-the-end iterator for the last encoding in the array still points to valid memory). Dereferencing an iterator can always return a valid array element, or "" for a non-dereferenceable iterator (but doing so will abort when assertions are enabled). In the language being proposed for C++26, dereferencing an invalid iterator erroneously returns "". Attempting to increment/decrement past the last/first element in the view is erroneously a no-op, so aborts when assertions are enabled, and doesn't change value otherwise. Similarly, constructing a std::text_encoding with an invalid id (one that doesn't have the value of an enumerator) erroneously behaves the same as constructing with id::unknown, or aborts with assertions enabled. libstdc++-v3/ChangeLog: PR libstdc++/113318 * acinclude.m4 (GLIBCXX_CONFIGURE): Add c++26 directory. (GLIBCXX_CHECK_TEXT_ENCODING): Define. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_TEXT_ENCODING. * include/Makefile.am: Add new headers. * include/Makefile.in: Regenerate. * include/bits/locale_classes.h (locale::encoding): Declare new member function. * include/bits/unicode.h (__charset_alias_match): New function. * include/bits/text_encoding-data.h: New file. * include/bits/version.def (text_encoding): Define. * include/bits/version.h: Regenerate. * include/std/text_encoding: New file. * src/Makefile.am: Add new subdirectory. * src/Makefile.in: Regenerate. * src/c++26/Makefile.am: New file. * src/c++26/Makefile.in: New file. * src/c++26/text_encoding.cc: New file. * src/experimental/Makefile.am: Include c++26 convenience library. * src/experimental/Makefile.in: Regenerate. * python/libstdcxx/v6/printers.py (StdTextEncodingPrinter): New printer. * scripts/gen_text_encoding_data.py: New file. * testsuite/22_locale/locale/encoding.cc: New test. * testsuite/ext/unicode/charset_alias_match.cc: New test. * testsuite/std/text_encoding/cons.cc: New test. * testsuite/std/text_encoding/members.cc: New test. * testsuite/std/text_encoding/requirements.cc: New test. Reviewed-by: Ulrich Drepper <drepper.fsp@gmail.com> Reviewed-by: Patrick Palka <ppalka@redhat.com>
2023-10-22Config,Darwin: Allow for configuring Darwin to use embedded runpath.Iain Sandoe1-0/+1
Recent Darwin versions place contraints on the use of run paths specified in environment variables. This breaks some assumptions in the GCC build. This change allows the user to configure a Darwin build to use '@rpath/libraryname.dylib' in library names and then to add an embedded runpath to executables (and libraries with dependents). The embedded runpath is added by default unless the user adds '-nodefaultrpaths' to the link line. For an installed compiler, it means that any executable built with that compiler will reference the runtimes installed with the compiler (equivalent to hard-coding the library path into the name of the library). During build-time configurations any "-B" entries will be added to the runpath thus the newly-built libraries will be found by exes. Since the install name is set in libtool, that decision needs to be available here (but might also cause dependent ones in Makefiles, so we need to export a conditional). This facility is not available for Darwin 8 or earlier, however the existing environment variable runpath does work there. We default this on for systems where the external DYLD_LIBRARY_PATH does not work and off for Darwin 8 or earlier. For systems that can use either method, if the value is unset, we use the default (which is currently DYLD_LIBRARY_PATH). ChangeLog: * configure: Regenerate. * configure.ac: Do not add default runpaths to GCC exes when we are building -static-libstdc++/-static-libgcc (the default). * libtool.m4: Add 'enable-darwin-at-runpath'. Act on the enable flag to alter Darwin libraries to use @rpath names. gcc/ChangeLog: * aclocal.m4: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. * config/darwin.h: Handle Darwin rpaths. * config/darwin.opt: Handle Darwin rpaths. * Makefile.in: Handle Darwin rpaths. gcc/ada/ChangeLog: * gcc-interface/Makefile.in: Handle Darwin rpaths. gcc/jit/ChangeLog: * Make-lang.in: Handle Darwin rpaths. libatomic/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libbacktrace/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. libgcc/ChangeLog: * config/t-slibgcc-darwin: Generate libgcc_s with an @rpath name. * config.host: Handle Darwin rpaths. libgfortran/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths libgm2/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. * libm2cor/Makefile.am: Handle Darwin rpaths. * libm2cor/Makefile.in: Regenerate. * libm2iso/Makefile.am: Handle Darwin rpaths. * libm2iso/Makefile.in: Regenerate. * libm2log/Makefile.am: Handle Darwin rpaths. * libm2log/Makefile.in: Regenerate. * libm2min/Makefile.am: Handle Darwin rpaths. * libm2min/Makefile.in: Regenerate. * libm2pim/Makefile.am: Handle Darwin rpaths. * libm2pim/Makefile.in: Regenerate. libgomp/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths libitm/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libobjc/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libphobos/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. * libdruntime/Makefile.am: Handle Darwin rpaths. * libdruntime/Makefile.in: Regenerate. * src/Makefile.am: Handle Darwin rpaths. * src/Makefile.in: Regenerate. libquadmath/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libsanitizer/ChangeLog: * asan/Makefile.am: Handle Darwin rpaths. * asan/Makefile.in: Regenerate. * configure: Regenerate. * hwasan/Makefile.am: Handle Darwin rpaths. * hwasan/Makefile.in: Regenerate. * lsan/Makefile.am: Handle Darwin rpaths. * lsan/Makefile.in: Regenerate. * tsan/Makefile.am: Handle Darwin rpaths. * tsan/Makefile.in: Regenerate. * ubsan/Makefile.am: Handle Darwin rpaths. * ubsan/Makefile.in: Regenerate. libssp/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libstdc++-v3/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. * src/Makefile.am: Handle Darwin rpaths. * src/Makefile.in: Regenerate. libvtv/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. lto-plugin/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. zlib/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths.
2023-09-15libstdc++: Implement C++26 native handles for file streams (P1759R6)Jonathan Wakely1-0/+3
The new __basic_file::native_handle() function can be added for C++11 and above, because the names "native_handle" and "native_handle_type" are already reserved since C++11. Exporting those symbols from the shared library does no harm, even if the feature gets dropped before the C++23 standard is final. The new member functions of std::fstream etc. are only declared for C++26 and so are not instantiated in src/c++11/fstream-inst.cc. Declare them with the always_inline attribute so that no symbol definitions are needed in the library (we can change this later when C++26 support is less experimental). libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_CHECK_FILEBUF_NATIVE_HANDLES): New macro. * config.h.in: Regenerate. * config/abi/pre/gnu.ver (GLIBCXX_3.4.32): Export new basic_filebuf members. * config/io/basic_file_stdio.cc (__basic_file::native_handle): Define new function. * config/io/basic_file_stdio.h (__basic_file::native_handle): Declare new function. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_FILEBUF_NATIVE_HANDLES. * include/bits/version.def (fstream_native_handles): New macro. * include/bits/version.h: Regenerate. * include/std/fstream (basic_filebuf::native_handle) (basic_fstream::native_handle, basic_ifstream::native_handle) (basic_ofstream::native_handle): New functions. * src/c++11/Makefile.am: Move compilation of basic_file.cc, locale_init.cc and localename.cc to here. * src/c++11/Makefile.in: Regenerate. * src/c++98/locale_init.cc: Moved to... * src/c++11/locale_init.cc: ...here. * src/c++98/localename.cc: Moved to... * src/c++11/localename.cc: ...here. * src/c++98/Makefile.am: Remove basic_file.cc, locale_init.cc and localename.cc from here. * src/c++98/Makefile.in: Regenerate. * testsuite/27_io/basic_filebuf/native_handle/version.cc: New test. * testsuite/27_io/basic_fstream/native_handle/char/1.cc: New test. * testsuite/27_io/basic_fstream/native_handle/wchar_t/1.cc: New test. * testsuite/27_io/basic_ifstream/native_handle/char/1.cc: New test. * testsuite/27_io/basic_ifstream/native_handle/wchar_t/1.cc: New test. * testsuite/27_io/basic_ofstream/native_handle/char/1.cc: New test. * testsuite/27_io/basic_ofstream/native_handle/wchar_t/1.cc: New test.
2023-09-04Revert "libstdc++: Use GLIBCXX_CHECK_LINKER_FEATURES for cross-builds ↵Christophe Lyon1-4/+0
(PR111238)" This reverts commit 46c2e94ca66ed9991c45a6ba6204ed02869efc39.
2023-09-04libstdc++: Use GLIBCXX_CHECK_LINKER_FEATURES for cross-builds (PR111238)Christophe Lyon1-0/+4
As discussed in PR104167 (comments #8 and below), and PR111238, using -Wl,-gc-sections in the libstdc++ testsuite for arm-eabi (cross-toolchain) avoids link failures for a few tests: 27_io/filesystem/path/108636.cc std/time/clock/gps/1.cc std/time/clock/gps/io.cc std/time/clock/tai/1.cc std/time/clock/tai/io.cc std/time/clock/utc/1.cc std/time/clock/utc/io.cc std/time/clock/utc/leap_second_info.cc std/time/exceptions.cc std/time/format.cc std/time/time_zone/get_info_local.cc std/time/time_zone/get_info_sys.cc std/time/tzdb/1.cc std/time/tzdb/leap_seconds.cc std/time/tzdb_list/1.cc std/time/zoned_time/1.cc std/time/zoned_time/custom.cc std/time/zoned_time/io.cc std/time/zoned_traits.cc This patch achieves this by calling GLIBCXX_CHECK_LINKER_FEATURES in cross-build cases, like we already do for native builds. We keep not doing so in Canadian-cross builds. However, this would hide the fact that libstdc++ somehow forces the user to use -Wl,-gc-sections to avoid undefined references to chdir, mkdir, chmod, pathconf, ... so maybe it's better to keep the status quo and not apply this patch? 2023-08-31 Christophe Lyon <christophe.lyon@linaro.org> libstdc++-v3/ChangeLog: PR libstdc++/111238 * configure: Regenerate. * configure.ac: Call GLIBCXX_CHECK_LINKER_FEATURES in cross, non-Canadian builds.
2023-06-30libstdc++: Fix iostream init for Clang on darwin [PR110432]Jonathan Wakely1-0/+3
The __has_attribute(init_priority) check in <iostream> is true for Clang on darwin, which means that user code including <iostream> thinks the library will initialize the global streams. However, when libstdc++ is built by GCC on darwin, the __has_attribute(init_priority) check is false, which means that the library thinks that user code will do the initialization when <iostream> is included. This means that the initialization is never done. Add an autoconf check so that the header and the library both make their decision based on the static properties of GCC at build time, with a consistent outcome. As a belt and braces check, also do the initialization in <iostream> if the compiler including that header doesn't support the attribute (even if the library also containers the initialization). This might result in redundant initialization done in <iostream>, but ensures the initialization happens somewhere if there's any doubt about the attribute working correctly due to missing linker support. libstdc++-v3/ChangeLog: PR libstdc++/110432 * acinclude.m4 (GLIBCXX_CHECK_INIT_PRIORITY): New. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_INIT_PRIORITY. * include/std/iostream: Use new autoconf macro as well as __has_attribute. * src/c++98/ios_base_init.h: Use new autoconf macro instead of __has_attribute. Reviewed-by: Patrick Palka <ppalka@redhat.com>
2023-06-16libstdc++-v3: do not duplicate some math functions when using newlibJoel Brobecker1-0/+9
When running the libstdc++ testsuite on AArch64 RTEMS, we noticed that about 25 tests are failing during the link, due to the "sqrtl" function being defined twice: - once inside RTEMS' libm; - once inside our libstdc++. One test that fails, for instance, would be 26_numerics/complex/13450.cc. In comparing libm and libstdc++, we found that libstc++ also duplicates "hypotf", and "hypotl". For "sqrtl" and "hypotl", the symbosl come a unit called from math_stubs_long_double.cc, while "hypotf" comes from the equivalent unit for the float version, called math_stubs_float.cc. Those units are always compiled in libstdc++ and provide our own version of various math routines when those are missing from the target system. The definition of those symbols is predicated on the existance of various macros provided by c++config.h, which themselves are predicated by the corresponding HAVE_xxx macros in config.h. One key element behind what's happening, here, is that the target uses newlib, and therefore GCC was configured --with-newlib. The section of libstdc++v3's configure script that handles which math functions are available has a newlib-specific section, and that section provides a hardcoded list of symbols. For "hypotf", this commit fixes the issue by doing the same as for the other routines already declared in that section. I verified by inspection in the newlib code that this function should always be present, so hardcoding it in our configure script should not be an issue. For the math routines handling doubles ("sqrtl" and "hypotl"), however, I do not believe we can assume that newlib's libm will always provide them. Therefore, this commit fixes that part of the issue by ading a compile-check for "sqrtl" and "hypotl". And while at it, we also include checks for all the other math functions that math_stubs_long_double.cc re-implements, allowing us to be resilient to future newlib enhancements adding support for more functions. libstdc++-v3/ChangeLog: * configure.ac ["x${with_newlib}" = "xyes"]: Define HAVE_HYPOTF. Add compile-checks for various long double math functions as well. * configure: Regenerate.
2023-06-07Revert "libstdc++: Use AS_IF in configure.ac"Jonathan Wakely1-10/+10
This reverts commit 97a5e8a2a48d162744a5bd60a012ce6fca13cbbe. libstdc++-v3/ChangeLog: * configure: Regenerate. * configure.ac:
2023-06-06libstdc++: Use AS_IF in configure.acJonathan Wakely1-10/+10
This ensures that anything that depends on AC_REQUIRE is hoisted out of the conditional block. The always-false test x"long_double_math_on_this_cpu" = x"yes" condition is not altered by this commit, only changed to use the AS_IF syntax. libstdc++-v3/ChangeLog: * configure.ac: Use AS_IF. * configure: Regenerate.
2023-05-31libstdc++: Replace obsolete shell syntax in configure.acJonathan Wakely1-1/+1
The current POSIX standard says that the -a and -o operators to the 'test' utility are obsolete, and the shell operators && and || should be used instead. libstdc++-v3/ChangeLog: * configure.ac: Replace use of -o operator for test. * configure: Regenerate.
2023-05-16libstdc++: Disable cacheline alignment for DJGPP [PR109741]Jonathan Wakely1-0/+3
DJGPP (and maybe other targets) uses MAX_OFILE_ALIGNMENT=16 which means that globals (and static objects) can't have alignment greater than 16. This causes an error for the locks defined in src/c++11/shared_ptr.cc because we try to align them to the cacheline size, to avoid false sharing. Add a configure check for the increased alignment, and live with false sharing where we can't increase the alignment. libstdc++-v3/ChangeLog: PR libstdc++/109741 * acinclude.m4 (GLIBCXX_CHECK_ALIGNAS_CACHELINE): Define. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_ALIGNAS_CACHELINE. * src/c++11/shared_ptr.cc (__gnu_internal::get_mutex): Do not align lock table if not supported. use __GCC_DESTRUCTIVE_SIZE instead of hardcoded 64.
2022-12-22libstdc++: Implement C++20 time zone support in <chrono>Jonathan Wakely1-0/+3
This is the largest missing piece of C++20 support. Only the cxx11 ABI is supported, due to the use of std::string in the API for time zones. For the old gcc4 ABI, utc_clock and leap seconds are supported, but only using a hardcoded list of leap seconds, no up-to-date tzdb::leap_seconds information is available, and no time zones or zoned_time conversions. The implementation currently depends on a tzdata.zi file being provided by the OS or the user. The expected location is /usr/share/zoneinfo but that can be changed using --with-libstdcxx-zoneinfo-dir=PATH. On targets that support it there is also a weak symbol that users can override in their own program (which also helps with testing): extern "C++" const char* __gnu_cxx::zoneinfo_dir_override(); If no file is found, a fallback tzdb object will be created which only contains the "Etc/UTC" and "Etc/GMT" time zones. A leapseconds file is also expected in the same directory, but if that isn't present then a hardcoded list of leapseconds is used, which is correct at least as far as 2023-06-28 (and it currently looks like no leap second will be inserted for a few years). The tzdata.zi and leapseconds files from https://www.iana.org/time-zones are in the public domain, so shipping copies of them with GCC would be an option. However, the tzdata.zi file will rapidly become outdated, so users should really provide it themselves (or convince their OS vendor to do so). It would also be possible to implement an alternative parser for the compiled tzdata files (one per time zone) under /usr/share/zoneinfo. Those files are present on more operating systems, but do not contain all the information present in tzdata.zi. Specifically, the "links" are not present, so that e.g. "UTC" and "Universal" are distinct time zones, rather than both being links to the canonical "Etc/UTC" zone. For some platforms those files are hard links to the same file, but there's no indication which zone is the canonical name and which is a link. Other platforms just store them in different inodes anyway. I do not plan to add such an alternative parser for the compiled files. That would need to be contributed by maintainers or users of targets that require it, if making tzdata.zi available is not an option. The library ABI would not need to change for a new tzdb implementation, because everything in tzdb_list, tzdb and time_zone is implemented as a pimpl (except for the shared_ptr links between nodes, described below). That means the new exported symbols added by this commit should be stable even if the implementation is completely rewritten. The information from tzdata.zi is parsed and stored in data structures that closely model the info in the file. This is a space-efficient representation that uses less memory that storing every transition for every time zone. It also avoids spending time expanding that information into time zone transitions that might never be needed by the program. When a conversion to/from a local time to UTC is requested the information will be processed to determine the time zone transitions close to the time being converted. There is a bug in some time zone transitions. When generating a sys_info object immediately after one that was previously generated, we need to find the previous rule that was in effect and note its offset and letters. This is so that the start time and abbreviation of the new sys_info will be correct. This only affects time zones that use a format like "C%sT" where the LETTERS replacing %s are non-empty for standard time, e.g. "Asia/Shanghai" which uses "CST" for standard time and "CDT" for daylight time. The tzdb_list structure maintains a linked list of tzdb nodes using shared_ptr links. This allows the iterators into the list to share ownership with the list itself. This offers a non-portable solution to a lifetime issue in the API. Because tzdb objects can be erased from the list using tzdb_list::erase_after, separate modules/libraries in a large program cannot guarantee that any const tzdb& or const time_zone* remains valid indefinitely. Holding onto a tzdb_list::const_iterator will extend the tzdb object's lifetime, even if it's erased from the list. An alternative design would be for the list iterator to hold a weak_ptr. This would allow users to test whether the tzdb still exists when the iterator is dereferenced, which is better than just having a dangling raw pointer. That doesn't actually extend the tzdb's lifetime though, and every use of it would need to be preceded by checking the weak_ptr. Using shared_ptr adds a little bit of overhead but allows users to solve the lifetime issue if they rely on the libstdc++-specific iterator property. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_ZONEINFO_DIR): New macro. * config.h.in: Regenerate. * config/abi/pre/gnu.ver: Export new symbols. * configure: Regenerate. * configure.ac (GLIBCXX_ZONEINFO_DIR): Use new macro. * include/std/chrono (utc_clock::from_sys): Correct handling of leap seconds. (nonexistent_local_time::_M_make_what_str): Define. (ambiguous_local_time::_M_make_what_str): Define. (__throw_bad_local_time): Define new function. (time_zone, tzdb_list, tzdb): Implement all members. (remote_version, zoned_time, get_leap_second_info): Define. * include/std/version: Add comment for __cpp_lib_chrono. * src/c++20/Makefile.am: Add new file. * src/c++20/Makefile.in: Regenerate. * src/c++20/tzdb.cc: New file. * testsuite/lib/libstdc++.exp: Define effective target tzdb. * testsuite/std/time/clock/file/members.cc: Check file_time alias and file_clock::now() member. * testsuite/std/time/clock/gps/1.cc: Likewise for gps_clock. * testsuite/std/time/clock/tai/1.cc: Likewise for tai_clock. * testsuite/std/time/syn_c++20.cc: Uncomment everything except parse. * testsuite/std/time/clock/utc/leap_second_info.cc: New test. * testsuite/std/time/exceptions.cc: New test. * testsuite/std/time/time_zone/get_info_local.cc: New test. * testsuite/std/time/time_zone/get_info_sys.cc: New test. * testsuite/std/time/time_zone/requirements.cc: New test. * testsuite/std/time/tzdb/1.cc: New test. * testsuite/std/time/tzdb/leap_seconds.cc: New test. * testsuite/std/time/tzdb_list/1.cc: New test. * testsuite/std/time/tzdb_list/requirements.cc: New test. * testsuite/std/time/zoned_time/1.cc: New test. * testsuite/std/time/zoned_time/custom.cc: New test. * testsuite/std/time/zoned_time/deduction.cc: New test. * testsuite/std/time/zoned_time/req_neg.cc: New test. * testsuite/std/time/zoned_time/requirements.cc: New test. * testsuite/std/time/zoned_traits.cc: New test.
2022-10-29libstdc++: Don't use gstdint.h anymoreArsen Arsenović1-6/+0
libstdc++-v3/ChangeLog: * configure.ac: Stop generating gstdint.h. * src/c++11/compatibility-atomic-c++0x.cc: Stop using gstdint.h. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * config.h.in: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * src/libbacktrace/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
2022-10-11libstdc++: Allow emergency EH alloc pool size to be tuned [PR68606]Jonathan Wakely1-0/+3
Implement a long-standing request to support tuning the size of the emergency buffer for allocating exceptions after malloc fails, or to disable that buffer entirely. It's now possible to disable the dynamic allocation of the buffer and use a fixed-size static buffer, via --enable-libstdcxx-static-eh-pool. This is a built-time choice that is baked into libstdc++ and so affects all code linked against that build of libstdc++. The size of the pool can be set by --with-libstdcxx-eh-pool-obj-count=N which is measured in units of sizeof(void*) not bytes. A given exception type such as std::system_error depends on the target, so giving a size in bytes wouldn't be portable across 16/32/64-bit targets. When libstdc++ is configured to use a dynamic buffer, the size of that buffer can now be tuned at runtime by setting the GLIBCXX_TUNABLES environment variable (c.f. PR libstdc++/88264). The number of exceptions to reserve space for is controlled by the "glibcxx.eh_pool.obj_count" and "glibcxx.eh_pool.obj_size" tunables. The pool will be sized to be able to allocate obj_count exceptions of size obj_size*sizeof(void*) and obj_count "dependent" exceptions rethrown by std::rethrow_exception. With the ability to tune the buffer size, we can reduce the default pool size on 32-bit and 16-bit targets. Most users never need to throw 1kB exceptions in parallel from hundreds of threads after malloc is OOM. The users who do need that can use the tunables to select larger sizes. The old defaults can be chosen at runtime by setting GLIBCXX_TUNABLES to: 64-bit: glibcxx.eh_pool.obj_count=64:glibcxx.eh_pool.obj_size=112 32-bit: glibcxx.eh_pool.obj_count=32:glibcxx.eh_pool.obj_size=104 Or approximated by configuring with: 64-bit: --with-libstdcxx-eh-pool-obj-count=252 32-bit: --with-libstdcxx-eh-pool-obj-count=94 libstdc++-v3/ChangeLog: PR libstdc++/68606 * Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro. * configure: Regenerate. * configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC. * crossconfig.m4: Check for secure_getenv. * doc/Makefile.in: Regenerate. * doc/xml/manual/configure.xml: Document new configure options. * doc/xml/manual/evolution.xml: Document addition of tunables. * doc/xml/manual/using_exceptions.xml: Document emergency buffer and tunables. * doc/html/*: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.am: Use EH_POOL_FLAGS. * libsupc++/Makefile.in: Regenerate. * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units of sizeof(void*) not including the ABI's exception header. (EMERGENCY_OBJ_COUNT): Define as target-independent calculation based on word size. (MAX_OBJ_COUNT): Define macro for upper limit on pool size. (pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer. (pool::buffer_size_in_bytes): New static member function. (pool::pool): Parse GLIBCXX_TUNABLES environment variable to set pool size at runtime. (pool::in_pool): Use std::less<void*> for total order. (__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing. (__cxa_free_exception, __cxa_free_dependent_exception): Add [[unlikely]] attributes. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * src/libbacktrace/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
2022-10-03libstdc++: Filter out unconditional <stdio.h> default includeArsen Arsenović1-0/+9
_AC_INCLUDES_DEFAULT_REQUIREMENTS including <stdio.h> when checking for stdint.h has prevented proper detection of whether stdint.h is present, since it'd poison the cache variables with test results failing due to <stdio.h> failing to include. As a solution, for autoconf versions under 2.70, we filter out that bit of code from ac_includes_default. This issue was fixed in autoconf-2.70. This also applies to various other headers, but was noticed when looking into why HAVE_STDINT_H was misdefined. libstdc++-v3/ChangeLog: * configure.ac: Remove any lines that unconditionally include <stdio.h> from ac_includes_default, when running Autoconf <2.70. * configure: Regenerate.
2022-07-19RTEMS: Remove HAVE_POLL for libstdc++Sebastian Huber1-1/+0
The poll() function is not always available in RTEMS. libstdc++-v3/ChangeLog: * configure: Regnerate. * configure.ac (newlib, *-rtems*): Remove HAVE_POLL.
2022-07-01Enable some features for RTEMS in libstdc++Sebastian Huber1-0/+25
Remove RTEMS support from crossconfig.m4 since this code is not used due to "with_newlib" being "yes". libstdc++-v3/ChangeLog: * configure: Regnerate. * configure.ac (newlib, *-rtems*): Enable TLS support for all RTEMS targets except bfin, lm32, mips, moxie, or1k, and v850. For all RTEMS targets, define HAVE_ALIGNED_ALLOC, HAVE_AT_QUICK_EXIT, HAVE_LINK, HAVE_POLL, HAVE_QUICK_EXIT, HAVE_READLINK, HAVE_SETENV, HAVE_SLEEP, HAVE_SOCKATMARK, HAVE_STRERROR_L, HAVE_SYMLINK, HAVE_TRUNCATE, and HAVE_USLEEP. * crossconfig.m4 (*-rtems*): Remove.
2022-01-19libstdc++: Remove -gdwarf-4 from flags for debug libraryJonathan Wakely1-1/+1
The default is -gdwarf-5 now, so this is hurting rather than improving things. libstdc++-v3/ChangeLog: * configure.ac (GLIBCXX_ENABLE_DEBUG_FLAGS): Remove -gdwarf-4 from default flags. * configure: Regenerate.
2022-01-17libstdc++: Define <stacktrace> header for C++23Jonathan Wakely1-0/+3
Add the <stacktrace> header and a new libstdc++_libbacktrace.a library that provides the implementation. For now, the new library is only built if --enable-libstdcxx-backtrace=yes is used. As with the Filesystem TS, the new library is only provided as a static archive. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): New macro. * configure.ac: Use GLIBCXX_ENABLE_BACKTRACE. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/std/stacktrace: New header. * include/std/version (__cpp_lib_stacktrace): Define. * Makefile.in: Regenerate. * config.h.in: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.am: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. * src/libbacktrace/Makefile.am: New file. * src/libbacktrace/Makefile.in: New file. * src/libbacktrace/backtrace-rename.h: New file. * src/libbacktrace/backtrace-supported.h.in: New file. * src/libbacktrace/config.h.in: New file. * testsuite/lib/libstdc++.exp (check_effective_target_stacktrace): New proc. * testsuite/20_util/stacktrace/entry.cc: New test. * testsuite/20_util/stacktrace/synopsis.cc: New test. * testsuite/20_util/stacktrace/version.cc: New test.
2022-01-10libstdc++: Fix and simplify freestanding configuration [PR103866]Jonathan Wakely1-2/+8
This fixes the --disable-hosted-libstdcxx build so that it works with --without-headers. Currently you need to also use --with-newlib, which is confusing for users who aren't actually using newlib. The AM_PROG_LIBTOOL checks are currently skipped for --with-newlib and --with-avrlibc builds, with this change they are also skipped when using --without-headers. It would be nice if using --disable-hosted-libstdcxx automatically skipped those checks, but GLIBCXX_ENABLE_HOSTED comes too late to make the AM_PROG_LIBTOOL checks depend on $is_hosted. The checks for EOF, SEEK_CUR etc. cause the build to fail if there is no <stdio.h> available. Unlike most headers, which get a HAVE_FOO_H macro, <stdio.h> is in autoconf's default includes, so every check tries to include it unconditionally. This change skips those checks for freestanding builds. Similarly, the checks for <stdint.h> types done by GCC_HEADER_STDINT try to include <stdio.h> and fail for --without-headers builds. This change skips the use of GCC_HEADER_STDINT for freestanding. We can probably stop using GCC_HEADER_STDINT entirely, since only one file uses the gstdint.h header that is generated, and that could easily be changed to use <stdint.h> instead. That can wait for stage 1. We also need to skip the GLIBCXX_CROSSCONFIG stage if --without-headers was used, since we don't have any of the functions it deals with. The end result of the changes above is that it should not be necessary for a --disable-hosted-libstdcxx --without-headers build to also use --with-newlib. Finally, compile libsupc++ with -ffreestanding when --without-headers is used, so that <stdint.h> will use <gcc-stdint.h> instead of expecting it to come from libc. libstdc++-v3/ChangeLog: PR libstdc++/103866 * acinclude.m4 (GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS): Do nothing for freestanding builds. (GLIBCXX_ENABLE_HOSTED): Define FREESTANDING_FLAGS. * configure.ac: Do not use AC_LIBTOOL_DLOPEN when configured with --without-headers. Do not use GCC_HEADER_STDINT for freestanding builds. * libsupc++/Makefile.am (HOSTED_CXXFLAGS): Use -ffreestanding for freestanding builds. * configure: Regenerate. * Makefile.in: Regenerate. * doc/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
2021-11-09libstdc++: Support getentropy and arc4random in std::random_deviceJonathan Wakely1-0/+4
This adds additional "getentropy" and "arc4random" tokens to std::random_device. The former is supported on Glibc and OpenBSD (and apparently wasm), and the latter is supported on various BSDs. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_CHECK_GETENTROPY, GLIBCXX_CHECK_ARC4RANDOM): Define. * configure.ac (GLIBCXX_CHECK_GETENTROPY, GLIBCXX_CHECK_ARC4RANDOM): Use them. * config.h.in: Regenerate. * configure: Regenerate. * src/c++11/random.cc (random_device): Add getentropy and arc4random as sources. * testsuite/26_numerics/random/random_device/cons/token.cc: Check new tokens. * testsuite/26_numerics/random/random_device/entropy.cc: Likewise.
2021-08-31libstdc++: Fix broken autoconf check for O_NONBLOCKJonathan Wakely1-4/+4
Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * configure.ac: Fix checks for F_GETFL, F_SETFL and O_NONBLOCK. * configure: Regenerate.
2021-08-26libstdc++: Make Networking TS headers more portable [PR100285]Jonathan Wakely1-0/+5
Add more preprocessor conditions to check for constants being defined before using them, so that the Networking TS headers can be compiled on a wider range of platforms. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/100285 * configure.ac: Check for O_NONBLOCK. * configure: Regenerate. * include/experimental/internet: Include <ws2tcpip.h> for Windows. Use preprocessor conditions around more constants. * include/experimental/socket: Use preprocessor conditions around more constants. * testsuite/experimental/net/internet/resolver/base.cc: Only use constants when the corresponding C macro is defined. * testsuite/experimental/net/socket/basic_socket.cc: Likewise. * testsuite/experimental/net/socket/socket_base.cc: Likewise. Make preprocessor checks more fine-grained.
2021-07-30libstdc++: Use secure_getenv for filesystem::temp_directory_path() [PR65018]Jonathan Wakely1-0/+1
This adds a configure check for the GNU extension secure_getenv and then uses it for looking up TMPDIR and similar variables. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/65018 * configure.ac: Check for secure_getenv. * config.h.in: Regenerate. * configure: Regenerate. * src/filesystem/ops-common.h (get_temp_directory_from_env): New helper function to obtain path from the environment. * src/c++17/fs_ops.cc (fs::temp_directory_path): Use new helper. * src/filesystem/ops.cc (fs::temp_directory_path): Likewise. * testsuite/27_io/filesystem/operations/temp_directory_path.cc: Print messages if test cannot be run. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Likewise. Fix incorrect condition. Use "TMP" to work with Windows as well as POSIX.
2021-05-04libstdc++: Remove _GLIBCXX_USE_INT128 autoconf macroJonathan Wakely1-1/+1
We don't need to decide whether to use __int128 when running configure, we can do so at compilation time by seeing if __SIZEOF_INT128__ is defined and if it's greater than __SIZEOF_LONG_LONG__. This removes another unnecessary architecture-specific config macro in <bits/c++config.h>, so the same header can work for 32-bit or 64-bit compilation on AIX. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_ENABLE_INT128_FLOAT128): Remove checks for __int128 and rename to GLIBCXX_ENABLE_FLOAT128. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Adjust to use GLIBCXX_ENABLE_FLOAT128. * include/bits/random.h (_Select_uint_least_t<s, 1>): Use __SIZEOF_INT128__ to decide whether to use __int128. * include/std/charconv (__to_chars_unsigned_type): Likewise.
2021-04-30libstdc++: Remove GLIBCXX_CHECK_INT64_T checksJonathan Wakely1-3/+0
This simplifies the definition of std::streamoff by using the predefined __INT64_TYPE__ macro, instead of the _GLIBCXX_HAVE_INT64_T_LONG, _GLIBCXX_HAVE_INT64_T_LONG_LONG and _GLIBCXX_HAVE_INT64_T macros defined by configure. By using the __INT64_TYPE__ macro (which all of GCC, Clang and Intel define) we do not need to determine the type of int64_t in configure, we can just use that type directly. The background for the change was explained by David Edelsohn: Currently the type of streamoff is determined at libstdc++ configure time, chosen by the definitions of _GLIBCXX_HAVE_INT64_T_LONG and _GLIBCXX_HAVE_INT64_T_LONG_LONG. For a multilib configuration, the difference is encoded in the different multilib header file paths. For "FAT" library targets that package 32 bit and 64 bit libraries together, G++ also expects a single header file directory hierarchy, causing an incorrect value for streamoff in some situations. And in a subsequent mail: Most of the libstdc++ headers are architecture-neutral, OS neutral and ABI neutral. The differences are localized in bits/c++config.h. And most of c++config.h is identical for 32 bit AIX and 64 bit AIX. The only differences that matter are __int128 and __int64_t. This change removes some of those differences. With the only uses of the INT64_T configure macros removed, the configure checks themselves can also be removed. Co-authored-by: David Edelsohn <dje.gcc@gmail.com> libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_CHECK_INT64_T): Delete. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Do not use GLIBCXX_CHECK_INT64_T. * include/bits/postypes.h: Remove include of <stdint.h> and definition/undefinition of the __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS macros. (streamoff): Use __INT64_TYPE__ if defined.
2020-12-16libstdc++: Add C++ runtime support for new 128-bit long double formatJonathan Wakely1-1/+36
This adds support for the new __ieee128 long double format on powerpc64le targets. Most of the complexity comes from wanting a single libstdc++.so library that contains the symbols needed by code compiled with both -mabi=ibmlongdouble and -mabi=ieeelongdouble (and not forgetting -mlong-double-64 as well!) In a few places this just requires an extra overload, for example std::from_chars has to be overloaded for both forms of long double. That can be done in a single translation unit that defines overloads for 'long double' and also '__ieee128', so that user code including <charconv> will be able to link to a definition for either type of long double. Those are the easy cases. The difficult parts are (as for the std::string ABI transition) the I/O and locale facets. In order to be able to write either form of long double to an ostream such as std::cout we need the locale to contain a std::num_put facet that can handle both forms. The same approach is taken as was already done for supporting 64-bit long double and 128-bit long double: adding extra overloads of do_put to the facet class. On targets where the new long double code is enabled, the facets that are registered in the locale at program startup have additional overloads so that they can work with any long double type. Where this fails to work is if user code installs its own facet, which will probably not have the additional overloads and so will only be able to output one or the other type. In practice the number of users expecting to be able to use their own locale facets in code using a mix of -mabi=ibmlongdouble and -mabi=ieeelongdouble is probably close to zero. libstdc++-v3/ChangeLog: * Makefile.in: Regenerate. * config.h.in: Regenerate. * config/abi/pre/gnu.ver: Make patterns less greedy. * config/os/gnu-linux/ldbl-ieee128-extra.ver: New file with patterns for IEEE128 long double symbols. * configure: Regenerate. * configure.ac: Enable alternative 128-bit long double format on powerpc64*-*-linux*. * doc/Makefile.in: Regenerate. * fragment.am: Regenerate. * include/Makefile.am: Set _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT. * include/Makefile.in: Regenerate. * include/bits/c++config: Define inline namespace for new long double symbols. Don't define _GLIBCXX_USE_FLOAT128 when it's the same type as long double. * include/bits/locale_classes.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT] (locale::_Impl::_M_init_extra_ldbl128): Declare new member function. * include/bits/locale_facets.h (_GLIBCXX_NUM_FACETS): Simplify by only counting narrow character facets. (_GLIBCXX_NUM_CXX11_FACETS): Likewise. (_GLIBCXX_NUM_LBDL_ALT128_FACETS): New. [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT] (num_get::__do_get): Define vtable placeholder for __ibm128 long double type. [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (num_get::__do_get): Declare vtable placeholder for __ibm128 long double type. [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (num_put::__do_put): Likewise. * include/bits/locale_facets.tcc [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (num_get::__do_get, num_put::__do_put): Define. * include/bits/locale_facets_nonio.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (money_get::__do_get): Declare vtable placeholder for __ibm128 long double type. [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (money_put::__do_put): Likewise. * include/bits/locale_facets_nonio.tcc [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (money_get::__do_get, money_put::__do_put): Define. * include/ext/numeric_traits.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT] (__numeric_traits<__ibm128>, __numeric_traits<__ieee128>): Define. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.am: Add compatibility-ldbl-alt128.cc and compatibility-ldbl-alt128-cxx11.cc sources and recipes for objects. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++11/compatibility-ldbl-alt128-cxx11.cc: New file defining symbols using the old 128-bit long double format, for the cxx11 ABI. * src/c++11/compatibility-ldbl-alt128.cc: Likewise, for the gcc4-compatible ABI. * src/c++11/compatibility-ldbl-facets-aliases.h: New header for long double compat aliases. * src/c++11/cow-locale_init.cc: Add comment. * src/c++11/cxx11-locale-inst.cc: Define C and C_is_char unconditionally. * src/c++11/cxx11-wlocale-inst.cc: Add sanity check. Include locale-inst.cc directly, not via cxx11-locale-inst.cc. * src/c++11/locale-inst-monetary.h: New header for monetary category instantiations. * src/c++11/locale-inst-numeric.h: New header for numeric category instantiations. * src/c++11/locale-inst.cc: Include new headers for monetary, numeric, and long double definitions. * src/c++11/wlocale-inst.cc: Remove long double compat aliases that are defined in new header now. * src/c++17/Makefile.am: Use -mabi=ibmlongdouble for floating_from_chars.cc. * src/c++17/Makefile.in: Regenerate. * src/c++17/floating_from_chars.cc (from_chars_impl): Add if-constexpr branch for __ieee128. (from_chars): Overload for __ieee128. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/c++98/locale_init.cc (num_facets): Adjust calculation. (locale::_Impl::_Impl(size_t)): Call _M_init_extra_ldbl128. * src/c++98/localename.cc (num_facets): Adjust calculation. (locale::_Impl::_Impl(const char*, size_t)): Call _M_init_extra_ldbl128. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. * testsuite/util/testsuite_abi.cc: Add new symbol versions. Allow new symbols to be added to GLIBCXX_IEEE128_3.4.29 and CXXABI_IEEE128_1.3.13 too. * testsuite/26_numerics/complex/abi_tag.cc: Add u9__ieee128 to regex matching expected symbols.
2020-12-16libstdc++: Test errno macros directly, not via autoconf [PR 93151]Jonathan Wakely1-1/+0
This fixes a bug caused by a mismatch between the macros defined by <errno.h> when GCC is built and the macros defined by <errno.h> when users include <system_error>. If the user code is compiled with _XOPEN_SOURCE defined to 500 or 600, Darwin suppresses the ENOTRECOVERABLE and EOWNERDEAD macros, which are not defined by SUSv3 (aka POSIX.1-2001). Since POSIX requires the errno macros to be macros (and not variables or enumerators) we can just test for them directly using the preprocessor. That means that <system_error> will match what is actuallydefined when it's included, not what was defined when GCC was built. With that change there is no need for the GLIBCXX_CHECK_SYSTEM_ERROR configure checks and they can be removed. libstdc++-v3/ChangeLog: PR libstdc++/93151 * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): Remove. * configure.ac: Regenerate. * config/os/generic/error_constants.h: Test POSIX errno macros directly, instead of corresponding _GLIBCXX_HAVE_EXXX macros. * testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc: Likewise. * testsuite/19_diagnostics/headers/system_error/93151.cc: New test.
2020-12-15libstdc++: Disabling AC_LIBTOOL_DLOPEN check if building with avr-libcVladimir Vishnevsky1-1/+1
The AC_LIBTOOL_DLOPEN checks were previously disabled for newlib targets. The patch applies similar logic to avr-libc based builds. libstdc++-v3/ChangeLog: * configure.ac: Skip AC_LIBTOOL_DLOPEN check if avr-libc is used. * configure: Regenerate.
2020-07-20libstdc++: Add std::from_chars for floating-point typesJonathan Wakely1-0/+5
This adds the missing std::from_chars overloads for floating-point types, as required for C++17 conformance. The implementation is a hack and not intended to be used in the long term. Rather than parsing the string directly, this determines the initial portion of the string that matches the pattern determined by the chars_format parameter, then creates a NTBS to be parsed by strtod (or strtold or strtof). Because creating a NTBS requires allocating memory, but std::from_chars is noexcept, we need to be careful to minimise allocation. Even after being careful, allocation failure is still possible, and so a non-conforming std::no_more_memory error code might be returned. Because strtod et al depend on the current locale, but std::from_chars does not, we change the current thread's locale to "C" using newlocale and uselocale before calling strtod, and restore it afterwards. Because strtod doesn't have the equivalent of a std::chars_format parameter, it has to examine the input to determine the format in use, even though the std::from_chars code has already parsed it once (or twice for large input strings!) By replacing the use of strtod we could avoid allocation, avoid changing locale, and use optimised code paths specific to each std::chars_format case. We would also get more portable behaviour, rather than depending on the presence of uselocale, and on any bugs or quirks of the target libc's strtod. Replacing strtod is a project for a later date. libstdc++-v3/ChangeLog: * acinclude.m4 (libtool_VERSION): Bump version. * config.h.in: Regenerate. * config/abi/pre/gnu.ver: Add GLIBCXX_3.4.29 version and new exports. * config/os/gnu-linux/ldbl-extra.ver: Add _GLIBCXX_LDBL_3.4.29 version and new export. * configure: Regenerate. * configure.ac: Check for <xlocale.h> and uselocale. * crossconfig.m4: Add macro or checks for uselocale. * include/std/charconv (from_chars): Declare overloads for float, double, and long double. * src/c++17/Makefile.am: Add new file. * src/c++17/Makefile.in: Regenerate. * src/c++17/floating_from_chars.cc: New file. (from_chars): Define for float, double, and long double. * testsuite/20_util/from_chars/1_c++20_neg.cc: Prune extra diagnostics caused by new overloads. * testsuite/20_util/from_chars/1_neg.cc: Likewise. * testsuite/20_util/from_chars/2.cc: Check leading '+'. * testsuite/20_util/from_chars/4.cc: New test. * testsuite/20_util/from_chars/5.cc: New test. * testsuite/util/testsuite_abi.cc: Add new symbol versions.
2020-06-21aix: Add GCC64 configuration and FAT target libraries.David Edelsohn1-0/+11
This patch adds the ability to configure GCC on AIX to build as a 64 bit application and to build target libraries "FAT" libraries in both 32 bit and 64 bit mode. The patch adds makefile fragment hooks to target libraries that allows them to include target-specific rules. The target specific rules for AIX place both 32 bit and 64 bit objects and shared objects in archives at the top-level, not multilib subdirectories. The multilibs are built in subdirectories, but must be combined during the last parts of the target library build process. Because of the way that GCC bootstrap works, the libraries must be combined during the multiple stages of GCC bootstrap, not solely when installed in the final destination, so the libraries are correct at the end of each target library build stage, not solely an install recipe. gcc/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * config.gcc: Use t-aix64, biarch64 and default64 for cpu_is_64bit. * config/rs6000/aix72.h (ASM_SPEC): Remove aix64 option. (ASM_SPEC32): New. (ASM_SPEC64): New. (ASM_CPU_SPEC): Remove vsx and altivec options. (CPP_SPEC_COMMON): Rename from CPP_SPEC. (CPP_SPEC32): New. (CPP_SPEC64): New. (CPLUSPLUS_CPP_SPEC): Rename to CPLUSPLUS_CPP_SPEC_COMMON.. (TARGET_DEFAULT): Only define if not BIARCH. (LIB_SPEC_COMMON): Rename from LIB_SPEC. (LIB_SPEC32): New. (LIB_SPEC64): New. (LINK_SPEC_COMMON): Rename from LINK_SPEC. (LINK_SPEC32): New. (LINK_SPEC64): New. (STARTFILE_SPEC): Add 64 bit version of crtcxa and crtdbase. (ASM_SPEC): Define 32 and 64 bit alternatives using DEFAULT_ARCH64_P. (CPP_SPEC): Same. (CPLUSPLUS_CPP_SPEC): Same. (LIB_SPEC): Same. (LINK_SPEC): Same. (SUBTARGET_EXTRA_SPECS): Add new 32/64 specs. * config/rs6000/defaultaix64.h: New file. * config/rs6000/t-aix64: New file. libgcc/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * config.host (extra_parts): Add crtcxa_64 and crtdbase_64. * config/rs6000/t-aix-cxa: Explicitly compile 32 bit with -maix32 and 64 bit with -maix64. * config/rs6000/t-slibgcc-aix: Remove extra @multilib_dir@ level. Build and install AIX-style FAT libraries. libgomp/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * Makefile.am (tmake_file): Build and install AIX-style FAT libraries. * Makefile.in: Regenerate * configure.ac (tmake_file): Substitute. * configure: Regenerate. * configure.tgt (powerpc-ibm-aix*): Define tmake_file. * config/t-aix: New file. libstdc++-v3/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * Makefile.am (tmake_file): Build and install AIX-style FAT libraries. * Makefile.in: Regenerate. * configure.ac (tmake_file): Substitute. * configure: Regenerate. * configure.host (aix*): Define tmake_file. * config/os/aix/t-aix: New file. libatomic/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * Makefile.am (tmake_file): Build and install AIX-style FAT libraries. * Makefile.in: Regenerate. * configure.ac (tmake_file): Substitute. * configure: Regenerate. * configure.tgt (powerpc-ibm-aix*): Define tmake_file. * config/t-aix: New file. libgfortran/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * Makefile.am (tmake_file): Build and install AIX-style FAT libraries. * Makefile.in: Regenerate. * configure.ac (tmake_file): Substitute. * configure: Regenerate. * configure.host: Add system configury stanza. Define tmake_file. * config/t-aix: New file.
2019-12-02libstdc++: Add full steady_clock support to shared_timed_mutexMike Crowe1-0/+3
The pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock functions were added to glibc in v2.30. They have also been added to Android Bionic. If these functions are available in the C library then they can be used to implement shared_timed_mutex::try_lock_until, shared_timed_mutex::try_lock_for, shared_timed_mutex::try_lock_shared_until and shared_timed_mutex::try_lock_shared_for so that they are no longer unaffected by the system clock being warped. (This is the shared_mutex equivalent of PR libstdc++/78237 for mutex.) If the new functions are available then steady_clock is deemed to be the "best" clock available which means that it is used for the relative try_lock_for calls and absolute try_lock_until calls using steady_clock and user-defined clocks. It's not possible to have _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK defined without _GLIBCXX_USE_PTHREAD_RWLOCK_T, so the requirement that the clock be the same as condition_variable is maintained. Calls explicitly using system_clock (aka high_resolution_clock) continue to use CLOCK_REALTIME via the old pthread_rwlock_timedrdlock and pthread_rwlock_timedwrlock functions. If the new functions are not available then system_clock is deemed to be the "best" clock available which means that the previous suboptimal behaviour remains. Additionally, the user-defined clock used with shared_timed_mutex::try_lock_for and shared_mutex::try_lock_shared_for may have higher precision than __clock_t. We may need to round the duration up to ensure that the timeout is long enough. (See __timed_mutex_impl::_M_try_lock_for) 2019-12-02 Mike Crowe <mac@mcrowe.com> Add full steady_clock support to shared_timed_mutex * acinclude.m4 (GLIBCXX_CHECK_PTHREAD_RWLOCK_CLOCKLOCK): Define to check for the presence of both pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock. * config.h.in: Regenerate. * configure.ac: Call GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK. * configure: Regenerate. * include/std/shared_mutex (shared_timed_mutex): Define __clock_t as the best clock to use for relative waits. (shared_timed_mutex::try_lock_for) Round up wait duration if necessary. (shared_timed_mutex::try_lock_shared_for): Likewise. (shared_timed_mutex::try_lock_until): Use existing try_lock_until implementation for system_clock (which matches __clock_t when _GLIBCCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK is not defined). Add new overload for steady_clock that uses pthread_rwlock_clockwrlock if it is available. Simplify overload for non-standard clock to just call try_lock_for with a relative timeout. (shared_timed_mutex::try_lock_shared_until): Likewise. From-SVN: r278903
2019-12-02libstdc++: PR 78237 Add full steady_clock support to timed_mutexMike Crowe1-0/+3
The pthread_mutex_clocklock function is available in glibc since the 2.30 release. If this function is available in the C library it can be used to fix PR libstdc++/78237 by supporting steady_clock properly with timed_mutex. This means that code using timed_mutex::try_lock_for or timed_mutex::wait_until with steady_clock is no longer subject to timing out early or potentially waiting for much longer if the system clock is warped at an inopportune moment. If pthread_mutex_clocklock is available then steady_clock is deemed to be the "best" clock available which means that it is used for the relative try_lock_for calls and absolute try_lock_until calls using steady_clock and user-defined clocks. Calls explicitly using system_clock (aka high_resolution_clock) continue to use CLOCK_REALTIME via __gthread_cond_timedwait. If pthread_mutex_clocklock is not available then system_clock is deemed to be the "best" clock available which means that the previous suboptimal behaviour remains. 2019-12-02 Mike Crowe <mac@mcrowe.com> PR libstdc++/78237 Add full steady_clock support to timed_mutex * acinclude.m4 (GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK): Define to detect presence of pthread_mutex_clocklock function. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Call GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK. * include/std/mutex (__timed_mutex_impl): Remove unnecessary __clock_t. (__timed_mutex_impl::_M_try_lock_for): Use best clock to turn relative timeout into absolute timeout. (__timed_mutex_impl::_M_try_lock_until): Keep existing implementation for system_clock. Add new implementation for steady_clock that calls _M_clocklock. Modify overload for user-defined clock to use a relative wait so that it automatically uses the best clock. [_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK] (timed_mutex::_M_clocklock): New member function. (recursive_timed_mutex::_M_clocklock): Likewise. From-SVN: r278901
2019-10-04Build filesystem library with large file supportJonathan Wakely1-0/+2
Enable AC_SYS_LARGEFILE to set the macros needed for large file APIs to be used by default. We do not want to define those macros in the public headers that users include. The values of the macros are copied to a separate file that is only included by the filesystem sources during the build, and then the macros in <bits/c++config.h> are renamed so that they don't have any effect in user code including our headers. Also use larger type for result of filesystem::file_size to avoid truncation of large values on 32-bit systems (PR 91947). PR libstdc++/81091 PR libstdc++/91947 * configure.ac: Use AC_SYS_LARGEFILE to enable 64-bit file APIs. * config.h.in: Regenerate: * configure: Regenerate: * include/Makefile.am (${host_builddir}/largefile-config.h): New target to generate config header for filesystem library. (${host_builddir}/c++config.h): Rename macros for large file support. * include/Makefile.in: Regenerate. * src/c++17/fs_dir.cc: Include new config header. * src/c++17/fs_ops.cc: Likewise. (filesystem::file_size): Use uintmax_t for size. * src/filesystem/dir.cc: Include new config header. * src/filesystem/ops.cc: Likewise. (experimental::filesystem::file_size): Use uintmax_t for size. From-SVN: r276585
2019-09-04PR libstdc++/41861 Add full steady_clock support to condition_variableMike Crowe1-0/+3
The pthread_cond_clockwait function is available in glibc since the 2.30 release. If this function is available in the C library it can be used to fix PR libstdc++/41861 by supporting std::chrono::steady_clock properly with std::condition_variable. This means that code using std::condition_variable::wait_for or std::condition_variable::wait_until with std::chrono::steady_clock is no longer subject to timing out early or potentially waiting for much longer if the system clock is warped at an inopportune moment. If pthread_cond_clockwait is available then std::chrono::steady_clock is deemed to be the "best" clock available which means that it is used for the relative wait_for calls and absolute wait_until calls using user-defined clocks. Calls explicitly using std::chrono::system_clock continue to use CLOCK_REALTIME via __gthread_cond_timedwait. If pthread_cond_clockwait is not available then std::chrono::system_clock is deemed to be the "best" clock available which means that the previous suboptimal behaviour remains. 2019-09-04 Mike Crowe <mac@mcrowe.com> PR libstdc++/41861 * acinclude.m4 (GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT): Check for new pthread_cond_clockwait function. * configure.ac: Use GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT. * configure: Regenerate. * config.h.in: Regenerate. * include/std/condition_variable: (condition_variable): Rename __steady_clock_t typedef and add system_clock. Change __clock_t to be a typedef for the preferred clock to convert arbitrary other clocks to. [_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT] (wait_until): Add a steady_clock overload. (wait_until): Change __clock_t overload to use system_clock. [_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT] (__wait_until_impl): Add steady_clock overload that calls pthread_cond_clockwait. (__wait_until_impl): Change __clock_t overload to use system_clock. (condition_variable_any) [_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT]: Use steady_clock for __clock_t if pthread_cond_clockwait is available. From-SVN: r275390
2019-07-01Fix libstdc++ install-pdf support.Jim Wilson1-0/+4
Generating pdf files requires everything that is required for the xml files except the style sheets. libstdc++-v3/ * configure.ac (BUILD_PDF): Also test for doxygen, dot, xsltproc, and xmllint. * configure: Regenerate. From-SVN: r272920
2019-05-29PR libstdc++/85494 use rdseed and rand_s in std::random_deviceJonathan Wakely1-0/+2
Add support for additional sources of randomness to std::random_device, to allow using RDSEED for Intel CPUs and rand_s for Windows. When supported these can be selected using the tokens "rdseed" and "rand_s". For *-w64-mingw32 targets the "default" token will now use rand_s, and for other i?86-*-* and x86_64-*-* targets it will try to use "rdseed" first, then "rdrand", and finally "/dev/urandom". To simplify the declaration of std::random_device in <bits/random.h> the constructors now unconditionally call _M_init instead of _M_init_pretr1, and the function call operator now unconditionally calls _M_getval. The library code now decides whether _M_init and _M_getval should use a real source of randomness or the mt19937 engine. Existing code compiled against old libstdc++ headers will still call _M_init_pretr1 and _M_getval_pretr1, but those functions now forward to _M_init and _M_getval if a real source of randomness is available. This means existing code compiled for mingw-w64 will start to use rand_s just by linking to a new libstdc++.dll. * acinclude.m4 (GLIBCXX_CHECK_X86_RDSEED): Define macro to check if the assembler supports rdseed. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_X86_RDSEED. * config/os/mingw32-w64/os_defines.h (_GLIBCXX_USE_CRT_RAND_S): Define. * doc/html/*: Regenerate. * doc/xml/manual/status_cxx2011.xml: Document new tokens. * include/bits/random.h (random_device::random_device()): Always call _M_init rather than _M_init_pretr1. (random_device::random_device(const string&)): Likewise. (random_device::operator()()): Always call _M_getval(). (random_device::_M_file): Replace first member of union with an anonymous struct, with _M_file as its first member. * src/c++11/random.cc [_GLIBCXX_X86_RDRAND] (USE_RDRAND): Define. [_GLIBCXX_X86_RDSEED] (USE_RDSEED): Define. (USE_MT19937): Define if none of the above are defined. (USE_POSIX_FILE_IO): Define. (_M_strtoul): Remove. [USE_RDSEED] (__x86_rdseed): Define new function. [_GLIBCXX_USE_CRT_RAND_S] (__winxp_rand_s): Define new function. (random_device::_M_init(const string&)): Initialize new union members. Add support for "rdseed" and "rand_s" tokens. Decide what the "default" token does according to which USE_* macros are defined. [USE_POSIX_FILE_IO]: Store a file descriptor. [USE_MT19937]: Forward to _M_init_pretr1 instead. (random_device::_M_init_pretr1(const string&)) [USE_MT19937]: Inline code from _M_strtoul. [!USE_MT19937]: Call _M_init, transforming the old default token or numeric tokens to "default". (random_device::_M_fini()) [USE_POSIX_FILE_IO]: Use close not fclose. (random_device::_M_getval()): Use new union members to obtain a random number from the stored function pointer or file descriptor. [USE_MT19937]: Obtain a value from the mt19937 engine. (random_device::_M_getval_pretr1()): Call _M_getval(). (random_device::_M_getentropy()) [USE_POSIX_FILE_IO]: Use _M_fd instead of fileno. [!USE_MT19937] (mersenne_twister): Do not instantiate when not needed. * testsuite/26_numerics/random/random_device/85494.cc: New test. From-SVN: r271740
2019-03-11PR libstdc++/89460 Fix Networking TS test failures on HP-UXJonathan Wakely1-0/+3
Check for availability of POSIX sockatmark before using it. Rename _S_ntoh overloads that are ambiguous when passed an integral type that is neither uint16_t nor uint32_t. PR libstdc++/89460 * configure.ac: Check for sockatmark. * crossconfig.m4: Check for sockatmark. * config.h.in: Regenerate. * configure: Regenerate. * include/experimental/internet (address_v4::_S_hton): Rename overloaded functions to _S_hton_16 and _S_ntoh_16. (address_v4::_S_ntoh): Rename to _S_ntoh_16 and _S_ntoh_32. (basic_endpoint): Adjust calls to _S_hton and _S_ntoh. * include/experimental/socket (basic_socket::at_mark): Check _GLIBCXX_HAVE_SOCKATMARK. From-SVN: r269588
2019-02-27PR libstdc++/89466 avoid slow xsltproc command in configureJonathan Wakely1-0/+1
Certain broken versions of xsltproc ignore the --nonet option and will attempt to fetch the docbook stylesheet from the WWW when it isn't in the local XML catalog. This patch checks for the local stylesheet directory first, and doesn't use xsltproc if no local stylesheets are found. Checking for the local directory is done using xmlcatalog if available, only checking the hardcoded list of directories if xmlcatalog fails. The right directory for Suse is added to the hardcoded list. This should avoid doing an xsltproc check that would need to download the stylesheet, so no network connection is made even if a broken xsltproc is present. PR libstdc++/89466 * acinclude.m4 (GLIBCXX_CONFIGURE_DOCBOOK): Reorder check for local stylesheet directories before check for xsltproc. Try to use xmlcatalog to find local stylesheet directory before trying hardcoded paths. Add path used by suse to hardcoded paths. Adjust xsltproc check to look for the same stylesheet as doc/Makefile.am uses. Don't use xsltproc if xmlcatalog fails to find a local stylesheet. * configure.ac: Check for xmlcatalog. * Makefile.in: Regenerate. * configure: Likewise. * doc/Makefile.in: Likewise. * include/Makefile.in: Likewise. * libsupc++/Makefile.in: Likewise. * po/Makefile.in: Likewise. * python/Makefile.in: Likewise. * src/Makefile.in: Likewise. * src/c++11/Makefile.in: Likewise. * src/c++17/Makefile.in: Likewise. * src/c++98/Makefile.in: Likewise. * src/filesystem/Makefile.in: Likewise. * testsuite/Makefile.in: Likewise. From-SVN: r269249
2019-02-14Add std::timespec and std::timespec_get for C++17Jonathan Wakely1-0/+3
* configure.ac: Check for C11 timespec_get function. * crossconfig.m4 (freebsd, linux, gnu, cygwin, solaris, netbsd) (openbsd): Likewise * config.h.in: Regenerate. * configure: Regenerate. * include/c_global/ctime (timespec, timespec_get): Add to namespace std for C++17 and up. From-SVN: r268879
2018-11-27PR libstdc++/67843 set shared_ptr lock policy at build-timeJonathan Wakely1-0/+1
This resolves a longstanding issue where the lock policy for shared_ptr reference counting depends on compilation options when the header is included, so that different -march options can cause ABI changes. For example, objects compiled with -march=armv7 will use atomics to synchronize reference counts, and objects compiled with -march=armv5t will use a mutex. That means the shared_ptr control block will have a different layout in different objects, causing ODR violations and undefined behaviour. This was the root cause of PR libstdc++/42734 as well as PR libstdc++/67843. The solution is to decide on the lock policy at build time, when libstdc++ is configured. The configure script checks for the availability of the necessary atomic built-ins for the target and fixes that choice permanently. Different -march flags used to compile user code will not cause changes to the lock policy. This results in an ABI change for certain compilations, but only where there was already an ABI incompatibility between the libstdc++.so library and objects built with an incompatible -march option. In general, this means a more stable ABI that isn't silently altered when -march flags make addition atomic ops available. To force a target to use "atomic" or "mutex" the new configure option --with-libstdcxx-lock-policy can be used. In order to turn ODR violations into linker errors, the uses of shared_ptr in filesystem directory iterators have been replaced with __shared_ptr, and explicit instantiations are declared. This ensures that object files using those types cannot link to libstdc++ libs unless they use the same lock policy. PR libstdc++/67843 * acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY): Add new macro that defines _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_ENABLE_LOCK_POLICY. * doc/xml/manual/configure.xml: Document new configure option. * include/bits/fs_dir.h (directory_iterator): Use __shared_ptr instead of shared_ptr. (recursive_directory_iterator): Likewise. (__shared_ptr<_Dir>): Add explicit instantiation declaration. (__shared_ptr<recursive_directory_iterator::_Dir_stack>): Likewise. * include/bits/shared_ptr_base.h (__allocate_shared, __make_shared): Add default template argument for _Lock_policy template parameter. * include/ext/concurrence.h (__default_lock_policy): Check macro _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY instead of checking if the current target supports the builtins for compare-and-swap. * src/filesystem/std-dir.cc (__shared_ptr<_Dir>): Add explicit instantiation definition. (__shared_ptr<recursive_directory_iterator::_Dir_stack>): Likewise. (directory_iterator, recursive_directory_iterator): Use __make_shared instead of make_shared. From-SVN: r266533
2018-10-31Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856).Joseph Myers1-1/+0
This patch updates GCC to use autoconf 2.69 and automake 1.15.1. (That's not the latest automake version, but it's the one used by binutils-gdb, with which consistency is desirable, and in any case seems a useful incremental update that should make a future update to 1.16.1 easier.) The changes are generally similar to the binutils-gdb ones, and are copied from there where shared files and directories are involved (there are some further changes to such shared directories, however, which I'd expect to apply to binutils-gdb once this patch is in GCC). Largely, obsolete AC_PREREQ calls are removed, while many AC_LANG_SOURCE calls are added to avoid warnings from aclocal and autoconf. Multilib support is no longer included in core automake, meaning that multilib.am needs copying from automake's contrib directory into the GCC source tree. Autoconf 2.69 has Go support, so local copies of that support are removed. I hope the D support will soon be submitted to upstream autoconf so the local copy of that can be removed in a future update. Changes to how automake generates runtest calls mean quotes are removed from RUNTEST definitions in five lib*/testsuite/Makefile.am files (libatomic, libgomp, libitm, libphobos, libvtv; some others have RUNTEST definitions without quotes, which are still OK); libgo and libphobos also get -Wno-override added to AM_INIT_AUTOMAKE so those overrides of RUNTEST do not generate automake warnings. Note that the regeneration did not include regeneration of fixincludes/config.h.in (attempting such regeneration resulted in all the USED_FOR_TARGET conditionals disappearing; and I don't see anything in the fixincludes/ directory that would result in such conditionals being generated, unlike in the gcc/ directory). Also note that libvtv/testsuite/other-tests/Makefile.in was not regenerated; that directory is not listed as a subdirectory for which Makefile.in gets regenerated by calling "automake" in libvtv/, so I'm not sure how it's meant to be regenerated. While I mostly fixed warnings should running aclocal / automake / autoconf, there were various such warnings from automake in the libgfortran, libgo, libgomp, liboffloadmic, libsanitizer, libphobos directories that I did not fix, preferring to leave those to the relevant subsystem maintainers. Specifically, most of those warnings were of the following form (example from libgfortran): Makefile.am:48: warning: source file 'caf/single.c' is in a subdirectory, Makefile.am:48: but option 'subdir-objects' is disabled automake: warning: possible forward-incompatibility. automake: At least a source file is in a subdirectory, but the 'subdir-objects' automake: automake option hasn't been enabled. For now, the corresponding output automake: object file(s) will be placed in the top-level directory. However, automake: this behaviour will change in future Automake versions: they will automake: unconditionally cause object files to be placed in the same subdirectory automake: of the corresponding sources. automake: You are advised to start using 'subdir-objects' option throughout your automake: project, to avoid future incompatibilities. I think it's best for the relevant maintainers to add subdir-objects and do any other associated Makefile.am changes needed. In some cases the paths in the warnings involved ../; I don't know if that adds any extra complications to the use of subdir-objects. I've tested this with native, cross and Canadian cross builds. The risk of any OS-specific issues should I hope be rather lower than if a libtool upgrade were included (we *should* do such an upgrade at some point, but it's more complicated - it involves identifying all our local libtool changes to see if any aren't included in the upstream version we update to, and reverting an upstream libtool patch that's inappropriate for use in GCC); I think it would be better to get this update into GCC so that people can test in different configurations and we can fix any issues found, rather than to try to get more and more testing done before it goes in. top level: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * multilib.am: New file. From automake. Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * libtool.m4: Use AC_LANG_SOURCE. * configure.ac: Remove AC_PREREQ, use AC_LANG_SOURCE. * ar-lib: New file. * test-driver: New file. * configure: Re-generate. config: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * math.m4, tls.m4: Use AC_LANG_SOURCE. Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * override.m4 (_GCC_AUTOCONF_VERSION): Bump from 2.64 to 2.69. fixincludes: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * aclocal.m4, configure: Regenerate. gcc: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. Use single line for second argument of AC_DEFINE_UNQUOTED. * doc/install.texi (Tools/packages necessary for modifying GCC): Update to autoconf 2.69 and automake 1.15.1. * aclocal.m4, config.in, configure: Regenerate. gnattools: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * configure: Regenerate. gotools: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * config/go.m4: Remove file. * Makefile.am (ACLOCAL_AMFLAGS): Do not use -I ./config. * configure.ac: Remove AC_PREREQ. Do not include config/go.m4. * Makefile.in, aclocal.m4, configure: Regenerate. intl: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Add AC_USE_SYSTEM_EXTENSIONS, remove AC_PREREQ. * configure: Re-generate. * config.h.in: Re-generate. * aclocal.m4: Re-generate. libada: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * configure: Regenerate. libatomic: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * acinclude.m4: Use AC_LANG_SOURCE. * configure.ac: Remove AC_PREREQ. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. libbacktrace: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * Makefile.in, aclocal.m4, config.h.in, configure: Regenerate. libcc1: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure: Regenerate. libcpp: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * aclocal.m4, config.in, configure: Regenerate. libdecnumber: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Remove AC_PREREQ. * configure: Re-generate. * aclocal.m4. libffi: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. (AUTOMAKE_OPTIONS): Add info-in-builddir. (CLEANFILES): Remove doc/libffi.info. * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure, fficonfig.h.in, include/Makefile.in, man/Makefile.in, testsuite/Makefile.in: Regenerate. libgcc: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * configure: Regenerate. libgfortran: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, config.h.in, configure: Regenerate. libgo [logically part of this change but omitted from the commit]: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * config/go.m4: Remove file. * config/libtool.m4: Use AC_LANG_SOURCE. * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. Use -Wno-override in AM_INIT_AUTOMAKE call. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. libgomp: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am (AUTOMAKE_OPTIONS): Add info-in-builddir. (CLEANFILES): Remove libgomp.info. * configure.ac: Remove AC_PREREQ. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. libhsail-rt: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure: Regenerate. libiberty: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Remove AC_PREREQ. * configure: Re-generate. * config.in: Re-generate. libitm: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. (AUTOMAKE_OPTIONS): Add info-in-builddir. (CLEANFILES): Remove libitm.info. * configure.ac: Remove AC_PREREQ. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. libobjc: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. * aclocal.m4, config.h.in, configure: Regenerate. liboffloadmic: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. * plugin/Makefile.am: Include multilib.am. * plugin/configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure, plugin/Makefile.in, plugin/aclocal.m4, plugin/configure: Regenerate. libphobos: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. Use -Wno-override in AM_INIT_AUTOMAKE call. * m4/autoconf.m4: Add extra argument to AC_LANG_DEFINE call. * m4/druntime/os.m4: Use AC_LANG_SOURCE. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, libdruntime/Makefile.in, src/Makefile.in, testsuite/Makefile.in: Regenerate. libquadmath: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. (AUTOMAKE_OPTIONS): Remove 1.8. Add info-in-builddir. (all-local): Define outside conditional code. (CLEANFILES): Remove libquadmath.info. * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, config.h.in, configure: Regenerate. libsanitizer: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * Makefile.in, aclocal.m4, asan/Makefile.in, configure, interception/Makefile.in, libbacktrace/Makefile.in, lsan/Makefile.in, sanitizer_common/Makefile.in, tsan/Makefile.in, ubsan/Makefile.in: Regenerate. libssp: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. (AUTOMAKE_OPTIONS): Remove 1.9.5. * configure.ac: Remove AC_PREREQ. Quote argument to AC_RUN_IFELSE. * Makefile.in, aclocal.m4, configure: Regenerate. libstdc++-v3: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. * Makefile.in, aclocal.m4, configure, doc/Makefile.in, include/Makefile.in, libsupc++/Makefile.in, po/Makefile.in, python/Makefile.in, src/Makefile.in, src/c++11/Makefile.in, src/c++17/Makefile.in, src/c++98/Makefile.in, src/filesystem/Makefile.in, testsuite/Makefile.in: Regenerate. libvtv: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. * configure.ac: Remove AC_PREREQ. * testsuite/Makefile.am (RUNTEST): Remove quotes. * Makefile.in, aclocal.m4, configure, testsuite/Makefile.in: Regenerate. lto-plugin: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * configure.ac: Remove AC_PREREQ. Use AC_LANG_SOURCE. * Makefile.in, aclocal.m4, config.h.in, configure: Regenerate. zlib: 2018-10-31 Joseph Myers <joseph@codesourcery.com> PR bootstrap/82856 * Makefile.am: Include multilib.am. Merge from binutils-gdb: 2018-06-19 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Modernize AC_INIT call, remove AC_PREREQ. * Makefile.am (AUTOMAKE_OPTIONS): Remove 1.8, cygnus, add foreign. * Makefile.in: Re-generate. * aclocal.m4: Re-generate. * configure: Re-generate. From-SVN: r265695
2018-10-16Use autoconf to check for features needed by Networking TSJonathan Wakely1-0/+3
* config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Check for headers used by Networking TS. * include/experimental/executor: Include <condition_variable> instead of <mutex>. * include/experimental/internet: Use autoconf macros for available headers. Include <sys/socket.h> for. Remove <cstring> and use __builtin_memcpy and __builtin_strchr. (resolver_errc) [!_GLIBCXX_HAVE_NETDB_H]: Do not define. (address_v4::to_string, address_v6::to_string) [!_GLIBCXX_HAVE_ARPA_INET_H]: Likewise. (basic_resolver_results) [!_GLIBCXX_HAVE_NETDB_H]: Make private constructors report errors. [!_GLIBCXX_HAVE_NETINET_TCP_H] (tcp::no_delay): Do not define. * include/experimental/io_context: Likewise. * include/experimental/socket: Likewise. [!_GLIBCXX_HAVE_SYS_SOCKET_H, !_GLIBCXX_HAVE_POLL_H] (socket_base): Do not define nested types when relevant header not available. (__socket_impl::native_non_blocking) [!_GLIBCXX_HAVE_FCNTL_H]: Report an error. (__basic_socket_impl::open, __basic_socket_impl::local_endpoint) (__basic_socket_impl::bind) [!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise. (__basic_socket_impl::io_control) [!_GLIBCXX_HAVE_SYS_IOCTL_H]: Likewise. (basic_socket::at_mark, basic_socket::shutdown) (basic_socket::remote_endpoint, basic_socket::connect) (basic_socket::async_connect) [!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise. (basic_socket::available) [_GLIBCXX_HAVE_SYS_IOCTL_H]: Check macro for <sys/ioctl.h> availability. (basic_socket::wait) [!_GLIBCXX_HAVE_POLL_H]: Likewise. (basic_datagram_socket::receive, basic_datagram_socket::async_receive) (basic_datagram_socket::receive_from) (basic_datagram_socket::async_receive_from) (basic_datagram_socket::send, basic_datagram_socket::async_send) (basic_datagram_socket::send_to, basic_datagram_socket::async_send_to) [!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise. (basic_stream_socket::receive, basic_stream_socket::async_receive) (basic_stream_socket::send, basic_stream_socket::async_send) [!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise. (basic_socket_acceptor::listen, basic_socket_acceptor::accept) (basic_socket_acceptor::async_accept) [!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise. (basic_socket_acceptor::wait) [!_GLIBCXX_HAVE_POLL_H]: Likewise. From-SVN: r265203
2018-10-16Define _GLIBCXX_USE_DEV_RANDOM as replacement for _GLIBCXX_USE_RANDOM_TR1Jonathan Wakely1-2/+2
Define and use a new macro with a more descriptive name. Only use the old macro in <tr1/random.h>. * acinclude.m4 (GLIBCXX_CHECK_RANDOM_TR1): Replace with ... (GLIBCXX_CHECK_DEV_RANDOM): New macro with more descriptive name. Define _GLIBCXX_USE_DEV_RANDOM as well as _GLIBCXX_USE_RANDOM_TR1. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_DEV_RANDOM instead of GLIBCXX_CHECK_RANDOM_TR1. crossconfig.m4: Likewise. * include/bits/random.h (random_device): Use _GLIBCXX_USE_DEV_RANDOM instead of _GLIBCXX_USE_RANDOM_TR1. * testsuite/26_numerics/random/random_device/cons/token.cc: Likewise. From-SVN: r265197
2018-08-13Revert "libstdc++-v3: Have aligned_alloc() on Newlib"Jonathan Wakely1-1/+0
This reverts commit r263461 / 2e920cd849b3cf0a72df4f172e27676a3e70b73f because aligned_alloc is not defined for baremetal newlib targets, see https://gcc.gnu.org/ml/libstdc++/2018-08/msg00065.html Revert 2018-08-10 Sebastian Huber <sebastian.huber@embedded-brains.de> PR target/85904 * configure.ac: Define HAVE_ALIGNED_ALLOC if building for Newlib. * configure: Regenerate. From-SVN: r263513
2018-08-10libstdc++-v3: Have aligned_alloc() on NewlibSebastian Huber1-0/+1
While building for Newlib, some configure checks must be hard coded. The aligned_alloc() is supported since 2015 in Newlib. libstdc++-v3/ PR target/85904 * configure.ac: Define HAVE_ALIGNED_ALLOC if building for Newlib. * configure: Regenerate. From-SVN: r263461