From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0151C3858C5E; Tue, 14 Mar 2023 13:07:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0151C3858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678799257; bh=Hci8zXl8kBMi3+YGcB5QZj5RyG7/G9kq1p4VoYpykCE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LLiTcaj7f2txB8rkYe6L6Ba1dlNuNCiCmnut1ClC9WM7Ra8c3709ojkYO1RS8OPCw 6+Gw7D+56XGLdS0ZqbhoZLvd46Zj35miHgNE0VMdtATIjWp3TNgzCt0QBmMxK2GPdx 2F0KAQNQ6T8J9YJDu112CJotOW7D3L8CotfWLirM= 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: Tue, 14 Mar 2023 13:07:36 +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 #2 from Tobias Burnus --- (In reply to Thomas Schwinge from comment #1) > See also "Allow the accelerator to have more offloaded functions than the= host". Which was: - if (num_target_entries !=3D num_funcs + num_vars) + if (num_target_entries < num_funcs + num_vars) I think this approach only works if functions are missing "at the end". The code does: gomp_load_image_to_device (..., const void *host_table, const void *target_data, ...) ... void **host_func_table =3D ((void ***) host_table)[0]; void **host_funcs_end =3D ((void ***) host_table)[1]; int num_funcs =3D host_funcs_end - host_func_table; ... num_target_entries =3D devicep->load_image_func (devicep->target_id, version, target_data, &target_table, ... k->host_start =3D (uintptr_t) host_func_table[i]; ... k->tgt_offset =3D target_table[i].start; Thus, it strictly depends on the order. That is: If some function "in the middle" is not linked in / part of 'host_table' alias '__OFFLOAD_TABLE__', = all remaining host<->device function and/or variable assignments are messed up.=