]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/uklibid: Option to store "Compiled-by" to `.uklibid_info`
authorSimon Kuenzer <simon@unikraft.io>
Fri, 6 Oct 2023 16:46:02 +0000 (19:46 +0300)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:35:55 +0000 (19:35 +0300)
Adds the option to store information about the person/entity/robot that was
compiling a library and unikernel. When enabled, the local system user and
hostname is used as default. For this purpose, the build system provides
`$(HOSTNAME)` and `$(HOSTUSER)`. Custom strings are also supported as well.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1117

Makefile
lib/uklibid/Config.uk
lib/uklibid/Makefile.uk
lib/uklibid/libinfo.S

index 2d58e50fbb6f79761189ce2a619070b65a4009e9..ad3af1d5e659bc250880fa1a6e9948e3dfabfe28 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -440,6 +440,8 @@ HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo ob
 HOSTRANLIB     := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
 HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
                   $(SED) -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1 \2/p')
+HOSTNAME       := $(shell hostname -s)
+HOSTUSER       := $(shell whoami)
 
 # For gcc >= 5.x, we only need the major version.
 ifneq ($(firstword $(HOSTCC_VERSION)),4)
index 36e87de3002a39d9c9b6a797b4b878fe7b27a741..a8599cd07d572405dbed912d121edede73b8753d 100644 (file)
@@ -76,6 +76,46 @@ config LIBUKLIBID_INFO
                                used for each library.
        endmenu
 
+       menuconfig LIBUKLIBID_INFO_COMPILEDBY
+               bool "Compiled by"
+               help
+                       Name of the person/entity that did the compilation.
+                       This information is added to each library and to the
+                       global metadata information of a unikernel.
+
+       if LIBUKLIBID_INFO_COMPILEDBY
+               config LIBUKLIBID_INFO_COMPILEDBY_HOST
+                       bool "Auto-detect name (user@hostname)"
+                       default y
+                       help
+                               Automatically retrieves "Compiled by"
+                               information by detecting the user
+                               and the host (user@hostname).
+
+               config LIBUKLIBID_INFO_COMPILEDBY_CUSTOM_TEXT
+                       string "Custom name"
+                       depends on !LIBUKLIBID_INFO_COMPILEDBY_HOST
+                       help
+                               This option can be used to set a custom name
+                               that is set as "Compiled by" information.
+
+               # Invisible option that enables auto-detecting user from host
+               config LIBUKLIBID_INFO_COMPILEDBY_CUSTOM
+                       bool
+                       default y if LIBUKLIBID_INFO_COMPILEDBY_CUSTOM_TEXT != ""
+
+               config LIBUKLIBID_INFO_COMPILEDBYASSOC_TEXT
+                       string "Association"
+                       help
+                               Additional "Compiled by" field for setting an
+                               association.
+
+               config LIBUKLIBID_INFO_COMPILEDBYASSOC
+                       bool
+                       default y if LIBUKLIBID_INFO_COMPILEDBYASSOC_TEXT != ""
+               endif
+       endif
+
        config LIBUKLIBID_INFO_BOOTDUMP
                bool "Print library summary early during boot"
                depends on LIBUKLIBID_INFO
index 354930864165f0b1b4c4e6fdd070bc561f1f05ae..110b3c4868dfcbeb46218500ebdfb6a5cbce46a6 100644 (file)
@@ -44,6 +44,7 @@ ASFLAGS += -D__LIBUKLIBID_COMPILER__="$(CC_INFO)"
 ASFLAGS-$(CONFIG_OPTIMIZE_PIE) += -D__LIBUKLIBID_COMPILEOPT_PIE__=1
 ASFLAGS-$(CONFIG_OPTIMIZE_LTO) += -D__LIBUKLIBID_COMPILEOPT_LTO__=1
 ASFLAGS-$(CONFIG_OPTIMIZE_DEADELIM) += -D__LIBUKLIBID_COMPILEOPT_DCE__=1
+ASFLAGS-$(CONFIG_LIBUKLIBID_INFO_COMPILEDBY_HOST) += -D__LIBUKLIBID_COMPILEDBY_HOST__="$(HOSTUSER)@$(HOSTNAME)"
 LIBUKLIBID_SRCS-$(CONFIG_LIBUKLIBID_INFO) +=  $(LIBUKLIBID_BASE)/infosec.ld
 LIBUKLIBID_SRCS-$(CONFIG_LIBUKLIBID_INFO) += $(LIBUKLIBID_BASE)/libinfo.S|global
 LIBUKLIBID_LIBINFO_GLOBAL_FLAGS-y += -D__GLOBALINFO__
index 642e2a9df6b393ea58977071d407321f7e9bd6c6..7178d1010d086af2d72f547131d7477946272796 100644 (file)
                        (!(!__LIBUKLIBID_COMPILEOPT_LTO__) * UKLI_REC_CO_LTO)))
 #endif /* !__GLOBALINFO__ */
 
+#if CONFIG_LIBUKLIBID_INFO_COMPILEDBY_HOST
+       RECORD(UKLI_REC_COMPILEDBY,
+              .asciz STRINGIFY(__LIBUKLIBID_COMPILEDBY_HOST__))
+#endif /* CONFIG_LIBUKLIBID_INFO_COMPILEDBY_HOST */
+#if CONFIG_LIBUKLIBID_INFO_COMPILEDBY_CUSTOM
+       RECORD(UKLI_REC_COMPILEDBY,
+              .asciz CONFIG_LIBUKLIBID_INFO_COMPILEDBY_CUSTOM_TEXT)
+#endif /* CONFIG_LIBUKLIBID_INFO_COMPILEDBY_CUSTOM */
+#if CONFIG_LIBUKLIBID_INFO_COMPILEDBYASSOC
+       RECORD(UKLI_REC_COMPILEDBYASSOC,
+              .asciz CONFIG_LIBUKLIBID_INFO_COMPILEDBYASSOC_TEXT)
+#endif /* CONFIG_LIBUKLIBID_INFO_COMPILEDBYASSOC */
+
 4:     .align 1
 .popsection