Skip to content

GH-137959: fix warning 'visibility' attribute ignored in jit/trampoline.c - #140286

Closed
chris-eibl wants to merge 1 commit into
python:mainfrom
chris-eibl:fix_hidden
Closed

GH-137959: fix warning 'visibility' attribute ignored in jit/trampoline.c#140286
chris-eibl wants to merge 1 commit into
python:mainfrom
chris-eibl:fix_hidden

Conversation

@chris-eibl

@chris-eiblchris-eibl commented Oct 18, 2025

Copy link
Copy Markdown
Member

Since #137961 we're getting this warning

/home/runner/work/cpython/cpython/Tools/jit/trampoline.c:13:13: warning: 'visibility' attribute ignored [-Wignored-attributes]
13 | typedef DECLARE_TARGET((*jit_func));
| ^
/home/runner/work/cpython/cpython/Tools/jit/jit.h:11:49: note: expanded from macro 'DECLARE_TARGET'
11 | _Py_CODEUNIT *__attribute__((preserve_none, visibility("hidden"))) \
| ^
1 warning generated.

for all platforms, e.g.
https://github.com/python/cpython/actions/runs/18575809544/job/52961278295?pr=140233
except i686-pc-windows-msvc, where this warning has to be suppressed

elifre.fullmatch(r"i686-pc-windows-msvc", host):
host="i686-pc-windows-msvc"
condition="defined(_M_IX86)"
# -Wno-ignored-attributes: __attribute__((preserve_none)) is not supported here.
args= ["-DPy_NO_ENABLE_SHARED", "-Wno-ignored-attributes"]

to silence the many warnings we'd get otherwise, because preserve_none is not supported there.

I suggest to use

// To use preserve_none in JIT builds, we need to declare a separate function
// pointer with __attribute__((preserve_none)), since this attribute may not be
// supported by the compiler used to build the rest of the interpreter.
typedefjit_func__attribute__((preserve_none)) jit_func_preserve_none;

I've verified with a small Godbolt demo and by comparing the emit_trampoline in the generated jit_stencils.h that the generated code remains the same.

@Fidget-Spinner

Copy link
Copy Markdown
Member

I think Savannah already opened a PR for this here #139981. Perhaps you could review it?

@chris-eibl

Copy link
Copy Markdown
MemberAuthor

Thanks Ken. Well spotted, I haven't seen Savannah's PR so closing mine.

@chris-eibl
chris-eibl deleted the fix_hidden branch November 15, 2025 10:23
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@chris-eibl@Fidget-Spinner