From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C7ABB3857C5F; Mon, 7 Sep 2020 11:25:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7ABB3857C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1599477955; bh=+wwOozjqMu8d32uZ9rxFkDUHzjb7GwCrH0f2wrRmZjQ=; h=From:To:Subject:Date:From; b=ruIVjh6YYvPFhruyoKEikbG155F/z6A9YxinZewEPrNdARfm2ewnOE02SIGYzVto3 D/bNp14MOGXh0QHnqMFbMtWtjUNwq4M1Xe0FgGSfmbTlzB4Jd735+RCbpFiEQC2l5U HEr9B8ubJWVeHXPNQhSFXehQRUL9KYmBnd5GXCUY= From: "sorear at fastmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/96952] New: __builtin_thread_pointer support cannot be probed Date: Mon, 07 Sep 2020 11:25:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sorear at fastmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2020 11:25:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96952 Bug ID: 96952 Summary: __builtin_thread_pointer support cannot be probed Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: sorear at fastmail dot com Target Milestone: --- I would like to use __builtin_thread_pointer instead of inline asm to access the thread pointer (concretely, in kernel or libc code for risc-v), but it's only supported by extremely recent versions of gcc and clang. So, I would = like to detect it at compile time, but this does not work: #if __has_builtin(__builtin_thread_pointer) void *get_tp() { return __builtin_thread_pointer(); } #else /* inline asm fallback */ #endif x.c: In function 'get_tp': x.c:2:25: error: '__builtin_thread_pointer' is not supported on this target 2 | void *get_tp() { return __builtin_thread_pointer(); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~ __has_builtin seems to be falsely returning true?=