Skip to content

Commit d0e7b0c

Browse files
committed
perf scripting python: Avoid declaring function pointers with a visibility attribute
To avoid this: util/scripting-engines/trace-event-python.c: In function 'python_start_script': util/scripting-engines/trace-event-python.c:1595:2: error: 'visibility' attribute ignored [-Werror=attributes] 1595 | PyMODINIT_FUNC (*initfunc)(void); | ^~~~~~~~~~~~~~ That started breaking when building with PYTHON=python3 and these gcc versions (I haven't checked with the clang ones, maybe it breaks there as well): # export PERF_TARBALL=http://192.168.86.5/perf/perf-5.9.0.tar.xz # dm fedora:33 fedora:rawhide 1 107.80 fedora:33 : Ok gcc (GCC) 10.2.1 20201005 (Red Hat 10.2.1-5), clang version 11.0.0 (Fedora 11.0.0-1.fc33) 2 92.47 fedora:rawhide : Ok gcc (GCC) 10.2.1 20201016 (Red Hat 10.2.1-6), clang version 11.0.0 (Fedora 11.0.0-1.fc34) # Avoid that by ditching that 'initfunc' function pointer with its: #define Py_EXPORTED_SYMBOL _attribute_ ((visibility ("default"))) #define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject* And just call PyImport_AppendInittab() at the end of the ifdef python3 block with the functions that were being attributed to that initfunc. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 9ae1e99 commit d0e7b0c

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

‎tools/perf/util/scripting-engines/trace-event-python.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,6 @@ static void _free_command_line(wchar_t **command_line, int num)
15921592
static int python_start_script(const char *script, int argc, const char **argv)
15931593
{
15941594
struct tables *tables = &tables_global;
1595-
PyMODINIT_FUNC (*initfunc)(void);
15961595
#if PY_MAJOR_VERSION < 3
15971596
const char **command_line;
15981597
#else
@@ -1607,20 +1606,18 @@ static int python_start_script(const char *script, int argc, const char **argv)
16071606
FILE *fp;
16081607

16091608
#if PY_MAJOR_VERSION < 3
1610-
initfunc = initperf_trace_context;
16111609
command_line = malloc((argc + 1) * sizeof(const char *));
16121610
command_line[0] = script;
16131611
for (i = 1; i < argc + 1; i++)
16141612
command_line[i] = argv[i - 1];
1613+
PyImport_AppendInittab(name, initperf_trace_context);
16151614
#else
1616-
initfunc = PyInit_perf_trace_context;
16171615
command_line = malloc((argc + 1) * sizeof(wchar_t *));
16181616
command_line[0] = Py_DecodeLocale(script, NULL);
16191617
for (i = 1; i < argc + 1; i++)
16201618
command_line[i] = Py_DecodeLocale(argv[i - 1], NULL);
1619+
PyImport_AppendInittab(name, PyInit_perf_trace_context);
16211620
#endif
1622-
1623-
PyImport_AppendInittab(name, initfunc);
16241621
Py_Initialize();
16251622

16261623
#if PY_MAJOR_VERSION < 3

0 commit comments

Comments
 (0)