Another option to prevent unwanted implicit dependencies.

Signed-off-by: Michael Olbrich <m.olbr...@pengutronix.de>
---
 doc/ref_make_variables.rst             | 8 ++++++++
 rules/post/ptxd_make_world_common.make | 1 +
 scripts/wrapper/libwrapper.sh          | 6 ++++++
 3 files changed, 15 insertions(+)

diff --git a/doc/ref_make_variables.rst b/doc/ref_make_variables.rst
index b770b1b49f18..674acdcea982 100644
--- a/doc/ref_make_variables.rst
+++ b/doc/ref_make_variables.rst
@@ -308,6 +308,14 @@ Build Environment for all Stages
   flags. Adding them via environment variables or ``make`` arguments can
   have unexpected side effects, such as as overwriting existing defaults.
 
+``<PKG>_FLAGS_BLACKLIST``
+  A list of arbitrary flags. If any one of these flags is found as an
+  argument to the compiler, preprocessor or linker then the call will fail.
+  This is useful to prevent implicit dependencies: Many packages try to
+  link to libraries at configure time and use them if it works. Adding
+  '-l<lib>' to the blacklist makes it possible to prevent such a detection
+  and explicitly avoid the dependency.
+
 ``<PKG>_WRAPPER_BLACKLIST``
   PTXdist has several options in the platformconfig that inject options in
   the compiler command line. This is used, for example, to add hardening
diff --git a/rules/post/ptxd_make_world_common.make 
b/rules/post/ptxd_make_world_common.make
index 172f4c3296af..e5cf50214e9c 100644
--- a/rules/post/ptxd_make_world_common.make
+++ b/rules/post/ptxd_make_world_common.make
@@ -94,6 +94,7 @@ world/env/impl = \
        pkg_build_dir="$(call ptx/escape,$($(1)_BUILD_DIR))"                    
\
                                                                                
\
        pkg_wrapper_blacklist="$(call ptx/escape,$($(1)_WRAPPER_BLACKLIST))"    
\
+       pkg_flags_blacklist="$(call ptx/escape,$($(1)_FLAGS_BLACKLIST))"        
\
                                                                                
\
        pkg_cppflags="$(call ptx/escape,$($(1)_CPPFLAGS))"                      
\
        pkg_cflags="$(call ptx/escape,$($(1)_CFLAGS))"                          
\
diff --git a/scripts/wrapper/libwrapper.sh b/scripts/wrapper/libwrapper.sh
index 0a970638a859..a7cdbeac05dd 100644
--- a/scripts/wrapper/libwrapper.sh
+++ b/scripts/wrapper/libwrapper.sh
@@ -103,6 +103,12 @@ cc_check_args() {
                                COMPILING=true
                                ;;
                esac
+               case " ${pkg_flags_blacklist} " in
+                       *" ${ARG} "*)
+                               echo "wrapper: found blacklisted flag '${ARG}'" 
>&2
+                               exit 1
+                               ;;
+               esac
        done
        # Used e.g. by the kernel to get the compiler version. Adding
        # linker options confuses gcc because there is nothing to link.
-- 
2.29.2


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to 
ptxdist-requ...@pengutronix.de

Reply via email to