From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 788333858CDB; Thu, 30 Mar 2023 14:42:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 788333858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680187375; bh=2o3yYLtQlXkjmEFRur9orlrJqOEL7Z4BUJyCrec2QTA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QqDBbQgcDoObp2dhe60A4IWhQZTkWoczpP/nF9RDyVqBC4pqGmaBGOBadrH39hdfy HA8lJRAl+ZG7OPz3/GED6BE3HM71da5DyhFaTO5ZQHONsqv3athayrXluwt6PoS1Vm 9rQICItH1AMgDfMtmJ51eunJL0DF+WpCgUMY/sMU= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/109128] [Offload][OpenMP][OpenACC] Static linking with unused offload function will lead to mismatch number of offload fn/symbols Date: Thu, 30 Mar 2023 14:42:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: openacc, openmp, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109128 --- Comment #3 from Tobias Burnus --- My initial thought was to handle it via lto1. This works well if all releva= nt files are compiled with "-flto" as then the callers of the offload function= s, the offload functions themselves are available, permitting to generate __OFFLOAD_TABLE__ directly. However, if -flto is not used or not used for all translation units (with offload code), this approach will fail due to visibility problems. Namely, the offload functions have local binding. This could be solved by forcing global binding (with visibility hidden), but this approach will fai= l if the assembler name is not unique. * * * Thus, placing the symbols into a section will work (current behavior), exce= pt that the linker might remove symbols (this bug) and one needs to hope that = the linking order is the same on the host as it is with LTO. Still remains the question how to handle this PR...=