tools: ynl: two patches to ease building with rpmbuild
Subsystems (3)
v2 cover tools: ynl: two patches to ease building with rpmbuild
I'm looking to build and package ynl for Fedora and Centos Stream users. Default rpmbuild has couple hardening options enabled by default [1][2], which currently prevent ynl from building.
This series contains 2 small patches to address it.
[1] https://fedoraproject.org/wiki/Changes/Harden_All_Packages
[2] https://fedoraproject.org/wiki/Changes/PythonSafePath
Changes in v2:
- rebased on top of https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/
Jan Stancek (2):
tools: ynl: add script dir to sys.path
tools: ynl: extend CFLAGS to keep options from environment
tools/net/ynl/cli.py | 3 +++ tools/net/ynl/ethtool.py | 2 ++ tools/net/ynl/generated/Makefile | 2 +- tools/net/ynl/lib/Makefile | 2 +- tools/net/ynl/samples/Makefile | 2 +- tools/net/ynl/ynl-gen-c.py | 3 +++ 6 files changed, 11 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 tools: ynl: add script dir to sys.path
Python options like PYTHONSAFEPATH or -P [1] do not add script directory to PYTHONPATH. ynl depends on this path to build and run.
[1] This option is default for Fedora rpmbuild since introduction of
https://fedoraproject.org/wiki/Changes/PythonSafePath
--- tools/net/ynl/cli.py | 3 +++ tools/net/ynl/ethtool.py | 2 ++ tools/net/ynl/ynl-gen-c.py | 3 +++ 3 files changed, 8 insertions(+)
tools/net/ynl/cli.py +3 -0
@@ -3,10 +3,13 @@ import argparse import json +import pathlib import pprint +import sys import time import signal +sys.path.append(pathlib.Path(__file__).resolve().parent.as_posix()) from lib import YnlFamily, Netlink, NlError
tools/net/ynl/ethtool.py +2 -0
@@ -3,11 +3,13 @@ import argparse import json +import pathlib import pprint import sys import re import os +sys.path.append(pathlib.Path(__file__).resolve().parent.as_posix()) from lib import YnlFamily def args_to_req(ynl, op_name, args, req):
tools/net/ynl/ynl-gen-c.py +3 -0
@@ -4,12 +4,15 @@ import argparse import collections import filecmp +import pathlib import os import re import shutil +import sys import tempfile import yaml +sys.path.append(pathlib.Path(__file__).resolve().parent.as_posix()) from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, SpecEnumEntry
Signature · 1 line
2.43.0
Re: [PATCH v2 1/2] tools: ynl: add script dir to sys.path
Quoted 8 lines · Jan Stancek
Python options like PYTHONSAFEPATH or -P [1] do not add script directory to PYTHONPATH. ynl depends on this path to build and run.
[1] This option is default for Fedora rpmbuild since introduction of
https://fedoraproject.org/wiki/Changes/PythonSafePathSigned-off-by Jan Stancek <[email protected]>Acked-by Jakub Kicinski <[email protected]>
PATCH v2 2/2 tools: ynl: extend CFLAGS to keep options from environment
In reply to Jan StancekPackage build environments like Fedora rpmbuild introduced hardening options (e.g. -pie -Wl,-z,now) by passing a -spec option to CFLAGS and LDFLAGS.
ynl Makefiles currently override CFLAGS but not LDFLAGS, which leads
to a mismatch and build failure:
CC sample devlink
/usr/bin/ld: devlink.o: relocation R_X86_64_32 against symbol `ynl_devlink_family' can not be used when making a PIE object; recompile with -fPIE /usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
Extend CFLAGS to support hardening options set by build environment.
--- tools/net/ynl/generated/Makefile | 2 +- tools/net/ynl/lib/Makefile | 2 +- tools/net/ynl/samples/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
tools/net/ynl/generated/Makefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 CC=gcc -CFLAGS=-std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \ +CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \ -I../lib/ -idirafter $(UAPI_PATH) ifeq ("$(DEBUG)","1") CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
tools/net/ynl/lib/Makefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 CC=gcc -CFLAGS=-std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow +CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow ifeq ("$(DEBUG)","1") CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan endif
tools/net/ynl/samples/Makefile +1 -1
@@ -3,7 +3,7 @@ include ../Makefile.deps CC=gcc -CFLAGS=-std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \ +CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \ -I../lib/ -I../generated/ -idirafter $(UAPI_PATH) ifeq ("$(DEBUG)","1") CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
Signature · 1 line
2.43.0
Re: [PATCH v2 2/2] tools: ynl: extend CFLAGS to keep options from environment
Quoted 11 lines · Jan Stancek
Package build environments like Fedora rpmbuild introduced hardening options (e.g. -pie -Wl,-z,now) by passing a -spec option to CFLAGS and LDFLAGS.
ynl Makefiles currently override CFLAGS but not LDFLAGS, which leads
to a mismatch and build failure:
CC sample devlink
/usr/bin/ld: devlink.o: relocationR_X86_64_32against symbol `ynl_devlink_family' can not be used when making a PIE object; recompile with -fPIE/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
Quoted 4 lines
Extend CFLAGS to support hardening options set by build environment.
Signed-off-by Jan Stancek <[email protected]>Acked-by Jakub Kicinski <[email protected]>
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 12 Nov 2024 09:21:31 +0100 you wrote:
I'm looking to build and package ynl for Fedora and Centos Stream users. Default rpmbuild has couple hardening options enabled by default [1][2], which currently prevent ynl from building.
This series contains 2 small patches to address it.
[1] https://fedoraproject.org/wiki/Changes/Harden_All_Packages
[2] https://fedoraproject.org/wiki/Changes/PythonSafePath[...]
Here is the summary with links:
- [v2,1/2] tools: ynl: add script dir to sys.path
https://git.kernel.org/netdev/net-next/c/c3b3eb565bd7 - [v2,2/2] tools: ynl: extend CFLAGS to keep options from environment https://git.kernel.org/netdev/net-next/c/05a318b4fc13
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html