Skip to content
Snippets Groups Projects
  1. Sep 28, 2022
    • Owen Rafferty's avatar
      kbuild: rewrite check-local-export in sh/awk · 033a52d0
      Owen Rafferty authored
      
      Remove the bash build dependency for those who otherwise do not
      have it installed. This also provides a significant speedup:
      
      $ make defconfig
      $ make yes2modconfig
      
      ...
      
      $ find  .  -name "*.o" | grep -v vmlinux | wc
           3169      3169     89615
      $ export NM=nm
      $ time sh -c 'find . -name "*.o" | grep -v vmlinux | xargs -n1
      ./scripts/check-local-export'
      
      Without patch:
          0m15.90s real     0m12.17s user     0m05.28s system
      
      With patch:
      dash + nawk
          0m02.16s real     0m02.92s user     0m00.34s system
      
      dash + busybox awk
          0m02.36s real     0m03.36s user     0m00.34s system
      
      dash + gawk
          0m02.07s real     0m03.26s user     0m00.32s system
      
      bash + gawk
          0m03.55s real     0m05.00s user     0m00.54s system
      
      Signed-off-by: default avatarOwen Rafferty <owen@owenrafferty.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      033a52d0
  2. Jun 09, 2022
  3. Jun 04, 2022
  4. Jun 01, 2022
    • Masahiro Yamada's avatar
      kbuild: check static EXPORT_SYMBOL* by script instead of modpost · 31cb50b5
      Masahiro Yamada authored
      
      The 'static' specifier and EXPORT_SYMBOL() are an odd combination.
      
      Commit 15bfc234 ("modpost: check for static EXPORT_SYMBOL*
      functions") tried to detect it, but this check has false negatives.
      
      Here is the sample code.
      
        Makefile:
      
          obj-y += foo1.o foo2.o
      
        foo1.c:
      
          #include <linux/export.h>
          static void foo(void) {}
          EXPORT_SYMBOL(foo);
      
        foo2.c:
      
          void foo(void) {}
      
      foo1.c exports the static symbol 'foo', but modpost cannot catch it
      because it is fooled by foo2.c, which has a global symbol with the
      same name.
      
      s->is_static is cleared if a global symbol with the same name is found
      somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily
      belong to the same compilation unit.
      
      This check should be done per compilation unit, but I do not know how
      to do it in modpost. modpost runs against vmlinux.o or modules, which
      merges multiple objects, then forgets their origin.
      
      modpost cannot parse individual objects because they may not be ELF but
      LLVM IR when CONFIG_LTO_CLANG=y.
      
      Add a simple bash script to parse the output from ${NM}. This works for
      CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files.
      
      Revert 15bfc234.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Tested-by: default avatarNathan Chancellor <nathan@kernel.org>
      Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
      31cb50b5
Loading