* [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild
@ 2024-11-12 8:21 Jan Stancek
2024-11-12 8:21 ` [PATCH v2 1/2] tools: ynl: add script dir to sys.path Jan Stancek
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jan Stancek @ 2024-11-12 8:21 UTC (permalink / raw)
To: donald.hunter, kuba
Cc: pabeni, davem, edumazet, horms, netdev, linux-kernel, jstancek
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(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] tools: ynl: add script dir to sys.path
2024-11-12 8:21 [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild Jan Stancek
@ 2024-11-12 8:21 ` Jan Stancek
2024-11-12 9:34 ` Donald Hunter
2024-11-12 8:21 ` [PATCH v2 2/2] tools: ynl: extend CFLAGS to keep options from environment Jan Stancek
2024-11-14 2:50 ` [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Jan Stancek @ 2024-11-12 8:21 UTC (permalink / raw)
To: donald.hunter, kuba
Cc: pabeni, davem, edumazet, horms, netdev, linux-kernel, jstancek
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
Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
---
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(+)
diff --git a/tools/net/ynl/cli.py b/tools/net/ynl/cli.py
index 9e95016b85b3..5e2913a7f3e4 100755
--- a/tools/net/ynl/cli.py
+++ b/tools/net/ynl/cli.py
@@ -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
diff --git a/tools/net/ynl/ethtool.py b/tools/net/ynl/ethtool.py
index 63c471f075ab..ebb0a11f67bf 100755
--- a/tools/net/ynl/ethtool.py
+++ b/tools/net/ynl/ethtool.py
@@ -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):
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index c48b69071111..394b0023b9a3 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -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
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] tools: ynl: extend CFLAGS to keep options from environment
2024-11-12 8:21 [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild Jan Stancek
2024-11-12 8:21 ` [PATCH v2 1/2] tools: ynl: add script dir to sys.path Jan Stancek
@ 2024-11-12 8:21 ` Jan Stancek
2024-11-12 9:35 ` Donald Hunter
2024-11-14 2:50 ` [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Jan Stancek @ 2024-11-12 8:21 UTC (permalink / raw)
To: donald.hunter, kuba
Cc: pabeni, davem, edumazet, horms, netdev, linux-kernel, jstancek
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: 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.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
---
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(-)
diff --git a/tools/net/ynl/generated/Makefile b/tools/net/ynl/generated/Makefile
index 713f5fb9cc2d..7db5240de58a 100644
--- a/tools/net/ynl/generated/Makefile
+++ b/tools/net/ynl/generated/Makefile
@@ -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
diff --git a/tools/net/ynl/lib/Makefile b/tools/net/ynl/lib/Makefile
index 2887cc5de530..94c49cca3dca 100644
--- a/tools/net/ynl/lib/Makefile
+++ b/tools/net/ynl/lib/Makefile
@@ -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
diff --git a/tools/net/ynl/samples/Makefile b/tools/net/ynl/samples/Makefile
index e194a7565861..c9494a564da4 100644
--- a/tools/net/ynl/samples/Makefile
+++ b/tools/net/ynl/samples/Makefile
@@ -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
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] tools: ynl: add script dir to sys.path
2024-11-12 8:21 ` [PATCH v2 1/2] tools: ynl: add script dir to sys.path Jan Stancek
@ 2024-11-12 9:34 ` Donald Hunter
0 siblings, 0 replies; 6+ messages in thread
From: Donald Hunter @ 2024-11-12 9:34 UTC (permalink / raw)
To: Jan Stancek; +Cc: kuba, pabeni, davem, edumazet, horms, netdev, linux-kernel
Jan Stancek <jstancek@redhat.com> writes:
> 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
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> Acked-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] tools: ynl: extend CFLAGS to keep options from environment
2024-11-12 8:21 ` [PATCH v2 2/2] tools: ynl: extend CFLAGS to keep options from environment Jan Stancek
@ 2024-11-12 9:35 ` Donald Hunter
0 siblings, 0 replies; 6+ messages in thread
From: Donald Hunter @ 2024-11-12 9:35 UTC (permalink / raw)
To: Jan Stancek; +Cc: kuba, pabeni, davem, edumazet, horms, netdev, linux-kernel
Jan Stancek <jstancek@redhat.com> writes:
> 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: 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.
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> Acked-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild
2024-11-12 8:21 [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild Jan Stancek
2024-11-12 8:21 ` [PATCH v2 1/2] tools: ynl: add script dir to sys.path Jan Stancek
2024-11-12 8:21 ` [PATCH v2 2/2] tools: ynl: extend CFLAGS to keep options from environment Jan Stancek
@ 2024-11-14 2:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-14 2:50 UTC (permalink / raw)
To: Jan Stancek
Cc: donald.hunter, kuba, pabeni, davem, edumazet, horms, netdev,
linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-14 2:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12 8:21 [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild Jan Stancek
2024-11-12 8:21 ` [PATCH v2 1/2] tools: ynl: add script dir to sys.path Jan Stancek
2024-11-12 9:34 ` Donald Hunter
2024-11-12 8:21 ` [PATCH v2 2/2] tools: ynl: extend CFLAGS to keep options from environment Jan Stancek
2024-11-12 9:35 ` Donald Hunter
2024-11-14 2:50 ` [PATCH v2 0/2] tools: ynl: two patches to ease building with rpmbuild patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).