1. 25 5月, 2020 11 次提交
  2. 17 5月, 2020 2 次提交
    • M
      kbuild: add infrastructure to build userspace programs · 7f3a59db
      Masahiro Yamada 提交于
      Kbuild supports the infrastructure to build host programs, but there
      was no support to build userspace programs for the target architecture
      (i.e. the same architecture as the kernel).
      
      Sam Ravnborg worked on this in 2014 (https://lkml.org/lkml/2014/7/13/154),
      but it was not merged. One problem at that time was, there was no good way
      to know whether $(CC) can link standalone programs. In fact, pre-built
      kernel.org toolchains [1] are often used for building the kernel, but they
      do not provide libc.
      
      Now, we can handle this cleanly because the compiler capability is
      evaluated at the Kconfig time. If $(CC) cannot link standalone programs,
      the relevant options are hidden by 'depends on CC_CAN_LINK'.
      
      The implementation just mimics scripts/Makefile.host
      
      The userspace programs are compiled with the same flags as the host
      programs. In addition, it uses -m32 or -m64 if it is found in
      $(KBUILD_CFLAGS).
      
      This new syntax has two usecases.
      
      - Sample programs
      
        Several userspace programs under samples/ include UAPI headers
        installed in usr/include. Most of them were previously built for
        the host architecture just to use the 'hostprogs' syntax.
      
        However, 'make headers' always works for the target architecture.
        This caused the arch mismatch in cross-compiling. To fix this
        distortion, sample code should be built for the target architecture.
      
      - Bpfilter
      
        net/bpfilter/Makefile compiles bpfilter_umh as the user mode helper,
        and embeds it into the kernel. Currently, it overrides HOSTCC with
        CC to use the 'hostprogs' syntax. This hack should go away.
      
      [1]: https://mirrors.edge.kernel.org/pub/tools/crosstool/Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: NSam Ravnborg <sam@ravnborg.org>
      7f3a59db
    • M
      kbuild: warn if always, hostprogs-y, or hostprogs-m is used · 59721d4e
      Masahiro Yamada 提交于
      always, hostprogs-y, and hostprogs-m are deprecated.
      
      There is no user in upstream code, but I will keep them for external
      modules. I want to remove them entirely someday. Prompt downstream
      users for the migration.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      59721d4e
  3. 12 5月, 2020 3 次提交
    • M
      kbuild: determine the output format of DTC by the target suffix · 78046fab
      Masahiro Yamada 提交于
      cmd_dtc takes the additional parameter $(2) to select the target
      format, dtb or yaml. This makes things complicated when it is used
      with cmd_and_fixdep and if_changed_rule. I actually stumbled on this.
      See commit 3d4b2238 ("kbuild: fix DT binding schema rule again to
      avoid needless rebuilds").
      
      Extract the suffix part of the target instead of passing the parameter.
      Fortunately, this works for both $(obj)/%.dtb and $(obj)/%.dt.yaml .
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      78046fab
    • M
      kbuild: use CONFIG_CC_VERSION_TEXT to construct LINUX_COMPILER macro · 9a950154
      Masahiro Yamada 提交于
      scripts/mkcompile_h runs $(CC) just for getting the version string.
      Reuse CONFIG_CC_VERSION_TEXT for optimization.
      
      For GCC, this slightly changes the version string. I do not think it
      is a big deal as we do not have the defined format for LINUX_COMPILER.
      In fact, the recent commit 4dcc9a88 ("kbuild: mkcompile_h:
      Include $LD version in /proc/version") added the linker version.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      9a950154
    • M
      kbuild: use -MMD instead of -MD to exclude system headers from dependency · 30a77297
      Masahiro Yamada 提交于
      This omits system headers from the generated header dependency.
      
      System headers are not updated unless you upgrade the compiler. Nor do
      they contain CONFIG options, so fixdep does not need to parse them.
      
      Having said that, the effect of this optimization will be quite small
      because the kernel code generally does not include system headers
      except <stdarg.h>. Host programs include a lot of system headers,
      but there are not so many in the kernel tree.
      
      At first, keeping system headers in .*.cmd files might be useful to
      detect the compiler update, but there is no guarantee that <stdarg.h>
      is included from every file. So, I implemented a more reliable way in
      the previous commit.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      30a77297
  4. 08 5月, 2020 2 次提交
  5. 05 5月, 2020 1 次提交
    • L
      gcc-10 warnings: fix low-hanging fruit · 9d82973e
      Linus Torvalds 提交于
      Due to a bug-report that was compiler-dependent, I updated one of my
      machines to gcc-10.  That shows a lot of new warnings.  Happily they
      seem to be mostly the valid kind, but it's going to cause a round of
      churn for getting rid of them..
      
      This is the really low-hanging fruit of removing a couple of zero-sized
      arrays in some core code.  We have had a round of these patches before,
      and we'll have many more coming, and there is nothing special about
      these except that they were particularly trivial, and triggered more
      warnings than most.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9d82973e
  6. 23 4月, 2020 2 次提交
  7. 22 4月, 2020 1 次提交
  8. 17 4月, 2020 1 次提交
    • M
      kbuild: check libyaml installation for 'make dt_binding_check' · 0903060f
      Masahiro Yamada 提交于
      If you run 'make dtbs_check' without installing the libyaml package,
      the error message "dtc needs libyaml ..." is shown.
      
      This should be checked also for 'make dt_binding_check' because dtc
      needs to validate *.example.dts extracted from *.yaml files.
      
      It is missing since commit 4f0e3a57 ("kbuild: Add support for DT
      binding schema checks"), but this fix-up is applicable only after commit
      e10c4321 ("kbuild: allow to run dt_binding_check and dtbs_check
      in a single command").
      
      I gave the Fixes tag to the latter in case somebody is interested in
      back-porting this.
      
      Fixes: e10c4321 ("kbuild: allow to run dt_binding_check and dtbs_check in a single command")
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      0903060f
  9. 16 4月, 2020 2 次提交
  10. 14 4月, 2020 2 次提交
    • F
      gcc-common.h: Update for GCC 10 · c7527373
      Frédéric Pierret (fepitre) 提交于
      Remove "params.h" include, which has been dropped in GCC 10.
      
      Remove is_a_helper() macro, which is now defined in gimple.h, as seen
      when running './scripts/gcc-plugin.sh g++ g++ gcc':
      
      In file included from <stdin>:1:
      ./gcc-plugins/gcc-common.h:852:13: error: redefinition of ‘static bool is_a_helper<T>::test(U*) [with U = const gimple; T = const ggoto*]’
        852 | inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
            |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from ./gcc-plugins/gcc-common.h:125,
                       from <stdin>:1:
      /usr/lib/gcc/x86_64-redhat-linux/10/plugin/include/gimple.h:1037:1: note: ‘static bool is_a_helper<T>::test(U*) [with U = const gimple; T = const ggoto*]’ previously declared here
       1037 | is_a_helper <const ggoto *>::test (const gimple *gs)
            | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Add -Wno-format-diag to scripts/gcc-plugins/Makefile to avoid
      meaningless warnings from error() formats used by plugins:
      
      scripts/gcc-plugins/structleak_plugin.c: In function ‘int plugin_init(plugin_name_args*, plugin_gcc_version*)’:
      scripts/gcc-plugins/structleak_plugin.c:253:12: warning: unquoted sequence of 2 consecutive punctuation characters ‘'-’ in format [-Wformat-diag]
        253 |   error(G_("unknown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
            |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NFrédéric Pierret (fepitre) <frederic.pierret@qubes-os.org>
      Link: https://lore.kernel.org/r/20200407113259.270172-1-frederic.pierret@qubes-os.org
      [kees: include -Wno-format-diag for plugin builds]
      Signed-off-by: NKees Cook <keescook@chromium.org>
      c7527373
    • K
      gcc-plugins/stackleak: Avoid assignment for unused macro argument · 8d97fb39
      Kees Cook 提交于
      With GCC version >= 8, the cgraph_create_edge() macro argument using
      "frequency" goes unused. Instead of assigning a temporary variable for
      the argument, pass the compute_call_stmt_bb_frequency() call directly
      as the macro argument so that it will just not be called when it is
      not wanted by the macros.
      
      Silences the warning:
      
      scripts/gcc-plugins/stackleak_plugin.c:54:6: warning: variable ‘frequency’ set but not used [-Wunused-but-set-variable]
      
      Now builds cleanly with gcc-7 and gcc-9. Both boot and pass
      STACKLEAK_ERASING LKDTM test.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      8d97fb39
  11. 08 4月, 2020 13 次提交