From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id CEB783839833 for ; Tue, 13 Jul 2021 03:16:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CEB783839833 Received: by mail-ed1-x530.google.com with SMTP id ee25so12882941edb.5 for ; Mon, 12 Jul 2021 20:16:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=quId8F9WtDkmnfm5HiKmwxrhIo+CYHMS7dod59/+ooE=; b=YodVgkFIZKMKeKB87MsG0hp/UrDKkaS3iuNqQGaduXoXz0p1CmwPwp9xoPUNzPuHjM 6LUJykyz0u0mr7XxCsCzYUkpucP3w2XsmSeEnDKdIzauxHpYC2hwFnKZz5qke2+5T8gw luFGoEdsZFv0d46vHlk5ZHNd9KEtidh/hbsRxmxQiqPQicl5lC6E3k6mlMQjC6bZvHTS n13nObC+zui5RRytMuU9Blop9Pjg27GxBwQJhPrgoHJGYsXi23q77b/KW2MCM8QV1QUv 96WNkXrSh4gp7gkvj07CeZBcW7yjq0982t/PtVrQFOCEig80j28qzjG+wMHXCPddIWNK 85WA== X-Gm-Message-State: AOAM530GWtbDn4E+hZJxU+HBy2WOT4VheIdC8eLd6DBDjeyEtFXCASux Nr/+GB8d6gjpUYcrntyS/xuhVUXiMz3SMCyBMFyI0lIybnkmqg== X-Google-Smtp-Source: ABdhPJwMK4XK+PqTjKYoEUwAs3hMU+456cMlLlCCQQ3t6/TECC3X2+5PzsSk0S1thcutAiQz2+9fVYQzrx1mlSxdhpc= X-Received: by 2002:a05:6402:216:: with SMTP id t22mr2587514edv.70.1626146188562; Mon, 12 Jul 2021 20:16:28 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?Q?Abra=C3=A3o_de_Santana?= Date: Tue, 13 Jul 2021 00:16:17 -0300 Message-ID: Subject: [PATCH] [android] Disable large files when unsupported To: gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2021 03:16:31 -0000 If C++ is enabled with Bionic on API Level < 24 ( and with NDK >= r15 as lower versions just ignore the issue ) you get errors of ::fgetpos and ::fsetpos error: 'fsetpos' has not been declared in '::' . The issue is that API Level < 24 doesn't implement large files (64 bit), so when _FILE_OFFSET_BITS is 64 and API Level < 24, the functions fgetpos, fsetpos, fseeko, and ftello are not defined. The behavior described above can be observed by going to 'android-ndk-rxxx/sysroot/usr/include/stdio.h' and watching the condition when those symbols are defined ( note: the control define __USE_FILE_OFFSET64 is defined if _FILE_OFFSET_BITS if 64) It's a known issue and bionic's docs ask you to stop defining _FILE_OFFSET_BITS to 64 to solve it: https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md Clang builds seem to get around this using libandroid_support on those cases ( android/ndk#480 ), which is not available when building the gnu std c++. libstdc++-v3/ChangeLog * config/os/bionic/os_defines.h: Undefines _FILE_OFFSET_BITS when it's 64-bit and Api Level < 24 --- libstdc++-v3/config/os/bionic/os_defines.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/config/os/bionic/os_defines.h b/libstdc++-v3/config/os/bionic/os_defines.h index c534838aea3..27605fa8baa 100644 --- a/libstdc++-v3/config/os/bionic/os_defines.h +++ b/libstdc++-v3/config/os/bionic/os_defines.h @@ -33,4 +33,16 @@ // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. +// If _FILE_OFFSET_BITS is 64 and __ANDROID_API__ < 24, there will be +// errors of undefined fgetpos, fsetpos, fseeko, and ftello because their +//64-bit versions are only available from API Level 24 onwards. +// +// See https://github.com/android/ndk/issues/480 +// +// See also +// https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md +#if (_FILE_OFFSET_BITS == 64) && (__ANDROID_API__ < 24) +#undef _FILE_OFFSET_BITS +#endif + #endif