20 Oct, 2020

1 commit

  • `hostname` may not be present on some systems as it's not mandated by
    POSIX/SUSv4. This isn't just a theoretical problem: on Arch Linux,
    `hostname` is provided by `inetutils`, which isn't part of the base
    distribution.

    ./scripts/mkcompile_h: line 38: hostname: command not found

    Use `uname -n` instead, which is more likely to be available (and
    mandated by standards).

    Signed-off-by: Chris Down
    Signed-off-by: Masahiro Yamada

    Chris Down
     

12 May, 2020

1 commit

  • 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 4dcc9a88448a ("kbuild: mkcompile_h:
    Include $LD version in /proc/version") added the linker version.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

08 Apr, 2020

1 commit

  • When doing Clang builds of the kernel, it is possible to link with
    either ld.bfd (binutils) or ld.lld (LLVM), but it is not possible to
    discover this from a running kernel. Add the "$LD -v" output to
    /proc/version.

    Signed-off-by: Kees Cook
    Reviewed-by: Nick Desaulniers
    Tested-by: Nick Desaulniers
    Reviewed-by: Nathan Chancellor
    Tested-by: Nathan Chancellor
    Reviewed-by: Fangrui Song
    Reviewed-by: Sedat Dilek
    Tested-by: Sedat Dilek
    Signed-off-by: Masahiro Yamada

    Kees Cook
     

02 Mar, 2020

1 commit

  • This reverts a very old commit, which dates back to the pre-git era:

    |commit 5d1cfb5b12f72145d30ba0f53c9f238144b122b8
    |Author: Kai Germaschewski
    |Date: Sat Jul 27 02:53:19 2002 -0500
    |
    | kbuild: Fix compiling/installing as different users
    |
    | "make bzImage && sudo make install" had the problem that during
    | the "sudo make install" the build system would notice that the information
    | in include/linux/compile.h is not accurate (it says "compiled by ",
    | but we are root), thus causing compile.h to be updated and leading to
    | some recompiles.
    |
    | We now only update "compile.h" if the current user is the owner of
    | include/linux/autoconf.h, i.e. the user who did the "make *config". So the
    | above sequence will correctly state "compiled by ".
    |
    |diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
    |index 6313db96172..cd956380978 100755
    |--- a/scripts/mkcompile_h
    |+++ b/scripts/mkcompile_h
    |@@ -3,6 +3,17 @@ ARCH=$2
    | SMP=$3
    | CC=$4
    |
    |+# If compile.h exists already and we don't own autoconf.h
    |+# (i.e. we're not the same user who did make *config), don't
    |+# modify compile.h
    |+# So "sudo make install" won't change the "compiled by "
    |+# do "compiled by root"
    |+
    |+if [ -r $TARGET -a ! -O ../include/linux/autoconf.h ]; then
    |+ echo ' (not modified)'
    |+ exit 0
    |+fi
    |+
    | if [ -r ../.version ]; then
    | VERSION=`cat ../.version`
    | else

    The 'make bzImage && sudo make install' problem no longer happens
    because commit 1648e4f80506 ("x86, kbuild: make "make install" not
    depend on vmlinux") fixed the root cause.

    Commit 19514fc665ff ("arm, kbuild: make "make install" not depend on
    vmlinux") fixed the similar issue on ARM, with detailed explanation.

    So, the rule is that the installation targets should never trigger
    the builds of any build artifact. By following it, this check is
    unneeded.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

14 Dec, 2019

2 commits

  • Commit 858805b336be ("kbuild: add $(BASH) to run scripts with
    bash-extension") shed light on portability issues. Here is another one.

    Since commit f07726048d59 ("Fix handling of backlash character in
    LINUX_COMPILE_BY name"), we must escape a backslash contained in
    LINUX_COMPILE_BY. This is not working on such distros as Ubuntu.

    As the POSIX spec [1] says, if any of the operands contain a backslash
    ( '\' ) character, the results are implementation-defined.

    The actual shell of /bin/sh could be bash, dash, etc. depending on
    distros, and the behavior of builtin echo command is different among
    them.

    The bash builtin echo, unless -e is given, copies the arguments to
    stdout without expanding escape sequences (BSD-like behavior).

    The dash builtin echo, in contrast, adopts System V behavior, which
    does expand escape sequences without any option given.

    Even non-builtin /bin/echo behaves differently depending on the system.
    Due to these variations, echo is considered as a non-portable command.
    Using printf is the common solution to avoid the portability issue.

    [1] https://pubs.opengroup.org/onlinepubs/009695399/utilities/echo.html

    Fixes: 858805b336be ("kbuild: add $(BASH) to run scripts with bash-extension")
    Reported-by: XXing Wei
    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     
  • UTS_VERSION is set to struct uts_namespace, hence a too long string
    should be truncated so it fits in 64 characters.

    On the other hand, LINUX_COMPILE_BY/HOST are not set to uts_namespace.
    They are just used in the banners, which do not have specific length
    limitation.

    I dug into the git history, but I could not find the reason why
    these two strings must fit in 64 characters. Remove them.

    Now that UTS_VERSION is the only user of UTS_TRUNCATE, I squashed it.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

14 Aug, 2019

1 commit

  • Update the build scripts and the version magic to reflect when
    CONFIG_PREEMPT_RT is enabled in the same way as CONFIG_PREEMPT is treated.

    The resulting version strings:

    Linux m 5.3.0-rc1+ #100 SMP Fri Jul 26 ...
    Linux m 5.3.0-rc1+ #101 SMP PREEMPT Fri Jul 26 ...
    Linux m 5.3.0-rc1+ #102 SMP PREEMPT_RT Fri Jul 26 ...

    The module vermagic:

    5.3.0-rc1+ SMP mod_unload modversions
    5.3.0-rc1+ SMP preempt mod_unload modversions
    5.3.0-rc1+ SMP preempt_rt mod_unload modversions

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Masahiro Yamada

    Thomas Gleixner
     

28 Jan, 2019

1 commit


18 Nov, 2017

1 commit

  • Pull Kbuild updates from Masahiro Yamada:
    "One of the most remarkable improvements in this cycle is, Kbuild is
    now able to cache the result of shell commands. Some variables are
    expensive to compute, for example, $(call cc-option,...) invokes the
    compiler. It is not efficient to redo this computation every time,
    even when we are not actually building anything. Kbuild creates a
    hidden file ".cache.mk" that contains invoked shell commands and their
    results. The speed-up should be noticeable.

    Summary:

    - Fix arch build issues (hexagon, sh)

    - Clean up various Makefiles and scripts

    - Fix wrong usage of {CFLAGS,LDFLAGS}_MODULE in arch Makefiles

    - Cache variables that are expensive to compute

    - Improve cc-ldopton and ld-option for Clang

    - Optimize output directory creation"

    * tag 'kbuild-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (30 commits)
    kbuild: move coccicheck help from scripts/Makefile.help to top Makefile
    sh: decompressor: add shipped files to .gitignore
    frv: .gitignore: ignore vmlinux.lds
    selinux: remove unnecessary assignment to subdir-
    kbuild: specify FORCE in Makefile.headersinst as .PHONY target
    kbuild: remove redundant mkdir from ./Kbuild
    kbuild: optimize object directory creation for incremental build
    kbuild: create object directories simpler and faster
    kbuild: filter-out PHONY targets from "targets"
    kbuild: remove redundant $(wildcard ...) for cmd_files calculation
    kbuild: create directory for make cache only when necessary
    sh: select KBUILD_DEFCONFIG depending on ARCH
    kbuild: fix linker feature test macros when cross compiling with Clang
    kbuild: shrink .cache.mk when it exceeds 1000 lines
    kbuild: do not call cc-option before KBUILD_CFLAGS initialization
    kbuild: Cache a few more calls to the compiler
    kbuild: Add a cache for generated variables
    kbuild: add forward declaration of default target to Makefile.asm-generic
    kbuild: remove KBUILD_SUBDIR_ASFLAGS and KBUILD_SUBDIR_CCFLAGS
    hexagon/kbuild: replace CFLAGS_MODULE with KBUILD_CFLAGS_MODULE
    ...

    Linus Torvalds
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

09 Oct, 2017

1 commit


19 Jun, 2017

1 commit


30 Apr, 2014

1 commit


10 Apr, 2014

1 commit


29 Apr, 2011

1 commit

  • When using a domain login, `whoami` returns the login in
    user\domain format. This leads to either warnings on unrecognised
    escape sequences or escaped characters being generated for the user.
    This patch ensures that any backslash is escaped to a double-backslash
    to make sure the name is preserved correctly. This patch does not
    enforce escaping on the KBUILD_BUILD_USER variable, as this is something
    the user has control of and can escape if required.

    Signed-off-by: Marcin Nowakowski
    Signed-off-by: Michal Marek

    Marcin Nowakowski
     

18 Apr, 2011

2 commits


02 Feb, 2010

1 commit


12 Dec, 2009

1 commit


12 Oct, 2009

2 commits


04 Dec, 2008

1 commit


03 May, 2007

1 commit

  • Introduce KBUILD_BUILD_VERSION to make it
    possible to override kernel build version
    during build time.

    Introduce KBUILD_BUILD_TIMESTAMP to make it
    possible to override kernel build timestamp
    during build time.

    But variables are useful mainly by distros
    that want to pass info from an SCM when
    building the kernel. Timestamp could be last
    checkin date for a file etc.

    The idea came from Olaf Hering

    Cc: Olaf Hering
    Signed-off-by: Sam Ravnborg

    Sam Ravnborg
     

15 Feb, 2007

1 commit

  • Fix a minor bug in mkcompile_h. As one can see, the current locale is used
    while getting the version of gcc. This produces problems when a locale
    other than C or en_US is used. As an example, my /proc/version contains
    Turkish characters in iso-8859-9 encoding.

    This patch fixes this issue by making sure that the C locale is used to get
    gcc's version.

    Cc: Sam Ravnborg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    s situert
     

15 Jul, 2005

1 commit

  • From: Matt Mackall

    Add PREEMPT to UTS_VERSION where enabled as is done for SMP to make
    preempt kernels easily identifiable.
    Added SMP PREEMPT as comment in compile.h to force it to be
    updated when they change (sam).

    Signed-off-by: Matt Mackall
    Signed-off-by: Sam Ravnborg

    Sam Ravnborg
     

17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds