Fixes for previous -dm pull request
v2 cover Fixes for previous -dm pull request
It turns out that the 'clang' support in buildman did not actually work, i.e. it failed to build with clang. This is because the U-Boot Makefile overrides the environment variables supplied by buildman. This series fixes that as well as an EFI loader warning that would be introduced by checking log() arguments.
This is sent as a new series on top of dm/master.
Changes in v2:
- Use the command line instead of environment for make variables
- Drop patches previously applied
- Add fixes needed to get clang building running
Simon Glass (7):
efi_loader: Add a wchar_t cast in efi_file_open()
log: Check printf() arguments
buildman: Add support for building with clang
travis: Use buildman for building with clang
net: Fix error handling in sb_eth_raw_ofdata_to_platdata()
buildman: Write the environment out to an 'env' file
buildman: Fix tabs in GetWrapper()
.travis.yml | 13 +++------- drivers/net/sandbox-raw.c | 9 ++++--- include/log.h | 3 ++- lib/efi_loader/efi_file.c | 4 ++-- tools/buildman/README | 10 ++++++++ tools/buildman/builderthread.py | 4 ++++ tools/buildman/cmdline.py | 2 ++ tools/buildman/control.py | 2 +- tools/buildman/toolchain.py | 42 ++++++++++++++++++++++++++++----- 9 files changed, 64 insertions(+), 25 deletions(-)
Signature · 1 line
2.20.1.97.g81188d93c3-goog
PATCH v2 1/7 efi_loader: Add a wchar_t cast in efi_file_open()
The printf() string here is not actually correct. Add a cast to avoid a warning when checking is enabled.
---
Changes in v2: None
lib/efi_loader/efi_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/efi_loader/efi_file.c +2 -2
@@ -221,8 +221,8 @@ static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file,struct file_handle *fh =to_fh (file);efi_status_t ret; -EFI_ENTRY ("%p, %p, \"%ls\", %llx, %llu" , file, new_handle, file_name, - open_mode, attributes); +EFI_ENTRY ("%p, %p, \"%ls\", %llx, %llu" , file, new_handle, + (wchar_t *)file_name, open_mode, attributes);/* Check parameters */ if (!file || !new_handle || !file_name) {
Signature · 1 line
2.20.1.97.g81188d93c3-goog
PATCH v2 1/7 efi_loader: Add a wchar_t cast in efi_file_open()
The printf() string here is not actually correct. Add a cast to avoid a warning when checking is enabled.
---
Changes in v2: None
lib/efi_loader/efi_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v2 1/7 efi_loader: Add a wchar_t cast in efi_file_open()
In reply to Simon GlassQuoted 16 lines · Simon Glass
The
printf()string here is not actually correct. Add a cast to avoid a warning when checking is enabled.Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
lib/efi_loader/efi_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/efi_loader/efi_file.c +0
-0
lib/efi_loader/efi_file.c static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file, · line 225
Quoted 7 lines
lib/efi_loader/efi_file.c +2
-2@@ -221,8 +221,8 @@ static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file,struct file_handle *fh =to_fh (file);efi_status_t ret; -EFI_ENTRY ("%p, %p, \"%ls\", %llx, %llu" , file, new_handle, file_name, - open_mode, attributes); +EFI_ENTRY ("%p, %p, \"%ls\", %llx, %llu" , file, new_handle, + (wchar_t *)file_name, open_mode, attributes);
Our utf-16 strings are all u16[].
Please, change file_name to be u16* both here and in include/efi_api.h. Then check every caller.
Best regards
Heinrich
Quoted 4 lines
lib/efi_loader/efi_file.c +0
-0/* Check parameters */ if (!file || !new_handle || !file_name) {
PATCH v2 1/7 efi_loader: Add a wchar_t cast in efi_file_open()
Quoted 27 lines · Heinrich Schuchardt
Quoted 16 lines · Simon Glass
The
printf()string here is not actually correct. Add a cast to avoid a warning when checking is enabled.Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
lib/efi_loader/efi_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/efi_loader/efi_file.c +0
-0lib/efi_loader/efi_file.c static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file, · line 225
Quoted 7 lines
lib/efi_loader/efi_file.c +2
-2@@ -221,8 +221,8 @@ static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file,struct file_handle *fh =to_fh (file);efi_status_t ret; -EFI_ENTRY ("%p, %p, \"%ls\", %llx, %llu" , file, new_handle, file_name, - open_mode, attributes); +EFI_ENTRY ("%p, %p, \"%ls\", %llx, %llu" , file, new_handle, + (wchar_t *)file_name, open_mode, attributes);Our utf-16 strings are all u16[].
Quoted 2 lines
Please, change
file_nameto be u16* both here and ininclude/efi_api.h. Then check every caller.
Thanks Simon for reporting. I have created a new patch
efi_loader: use u16* for file name
https://lists.denx.de/pipermail/u-boot/2019-January/354375.html
Best regards
Heinrich
PATCH v2 1/7 efi_loader: Add a wchar_t cast in efi_file_open()
Quoted 29 lines · Heinrich Schuchardt
Quoted 27 lines · Heinrich Schuchardt
Quoted 16 lines · Simon Glass
The
printf()string here is not actually correct. Add a cast to avoid a warning when checking is enabled.Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
lib/efi_loader/efi_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/efi_loader/efi_file.c +0
-0lib/efi_loader/efi_file.c static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file, · line 225
Quoted 7 lines
lib/efi_loader/efi_file.c +2
-2@@ -221,8 +221,8 @@ static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file,struct file_handle *fh =to_fh (file);efi_status_t ret; -EFI_ENTRY ("%p, %p, \"%ls\", %llx, %llu" , file, new_handle, file_name, - open_mode, attributes); +EFI_ENTRY ("%p, %p, \"%ls\", %llx, %llu" , file, new_handle, + (wchar_t *)file_name, open_mode, attributes);Our utf-16 strings are all u16[].
Quoted 8 lines
Quoted 2 lines
Please, change
file_nameto be u16* both here and ininclude/efi_api.h. Then check every caller.Thanks Simon for reporting. I have created a new patch
efi_loader: use u16* for file name
https://lists.denx.de/pipermail/u-boot/2019-January/354375.html
Great thanks! I'll drop my one.
- Simon
PATCH v2 2/7 log: Check printf() arguments
In reply to Simon GlassAt present logging does not check printf() arguments. Now that all users have been corrected, enable this to prevent further problems.
---
Changes in v2: None
include/log.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/log.h +2 -1
@@ -73,7 +73,8 @@ static inline int log_uc_cat(enum uclass_id id)* @return 0 if log record was emitted, -ve on error */ int _log (enum log_category_t cat,enum log_level_t level,const char *file, -int line,const char *func,const char *fmt, ...); +int line,const char *func,const char *fmt, ...) + __attribute__ ((format (__printf__,6 ,7 )));/* Define this at the top of a file to add a prefix to debug messages */ #ifndef pr_fmt
Signature · 1 line
2.20.1.97.g81188d93c3-goog
PATCH v2 2/7 log: Check printf() arguments
At present logging does not check printf() arguments. Now that all users have been corrected, enable this to prevent further problems.
---
Changes in v2: None
include/log.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v2 3/7 buildman: Add support for building with clang
In reply to Simon GlassAdd a -O option which allows building with clang.
---
Changes in v2:
- Use the command line instead of environment for make variables
tools/buildman/README | 10 +++++++++ tools/buildman/builderthread.py | 1 + tools/buildman/cmdline.py | 2 ++ tools/buildman/control.py | 2 +- tools/buildman/toolchain.py | 38 +++++++++++++++++++++++++++++---- 5 files changed, 48 insertions(+), 5 deletions(-)
tools/buildman/README +10 -0
@@ -1046,6 +1046,16 @@ value for 'altbootcmd', but lost one for ' altbootcmd'. The -U option uses the u-boot.env files which are produced by a build. + +Building with clang +=================== + +To build with clang (sandbox only), use the -O option to override the +toolchain. For example: + + buildman -O clang-7 --board sandbox + + Other options =============
tools/buildman/builderthread.py +1 -0
@@ -229,6 +229,7 @@ class BuilderThread(threading.Thread): config_args = ['%s_defconfig' % brd.target] config_out = '' args.extend(self.builder.toolchains.GetMakeArguments(brd)) + args.extend(self.toolchain.MakeArgs()) # If we need to reconfigure, do that now if do_config:
tools/buildman/cmdline.py +2 -0
@@ -74,6 +74,8 @@ def ParseArgs(): parser.add_option('-o', '--output-dir', type='string', dest='output_dir', default='..', help='Directory where all builds happen and buildman has its workspace (default is ../)') + parser.add_option('-O', '--override-toolchain', type='string', + help="Override host toochain to use for sandbox (e.g. 'clang-7')") parser.add_option('-Q', '--quick', action='store_true', default=False, help='Do a rough build, with limited warning resolution') parser.add_option('-p', '--full-path', action='store_true',
tools/buildman/control.py +1 -1
@@ -141,7 +141,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, no_toolchains = toolchains is None if no_toolchains: - toolchains = toolchain.Toolchains() + toolchains = toolchain.Toolchains(options.override_toolchain) if options.fetch_arch: if options.fetch_arch == 'list':
tools/buildman/toolchain.py +34 -4
@@ -54,9 +54,11 @@ class Toolchain: arch: Architecture of toolchain as determined from the first component of the filename. E.g. arm-linux-gcc becomes arm priority: Toolchain priority (0=highest, 20=lowest) + override_toolchain: Toolchain to use for sandbox, overriding the normal + one """ def __init__(self, fname, test, verbose=False, priority=PRIORITY_CALC, - arch=None): + arch=None, override_toolchain=None): """Create a new toolchain object. Args:
@@ -68,6 +70,7 @@ class Toolchain: """ self.gcc = fname self.path = os.path.dirname(fname) + self.override_toolchain = override_toolchain # Find the CROSS_COMPILE prefix to use for U-Boot. For example, # 'arm-linux-gnueabihf-gcc' turns into 'arm-linux-gnueabihf-'.
@@ -81,6 +84,8 @@ class Toolchain: self.arch = arch else: self.arch = self.cross[:pos] if pos != -1 else 'sandbox' + if self.arch == 'sandbox' and override_toolchain: + self.gcc = override_toolchain env = self.MakeEnvironment(False)
@@ -150,11 +155,18 @@ class Toolchain: Args: full_path: Return the full path in CROSS_COMPILE and don't set PATH + Returns: + Dict containing the environemnt to use. This is based on the current + environment, with changes as needed to CROSS_COMPILE, PATH and + LC_ALL. """ env = dict(os.environ) wrapper = self.GetWrapper() - if full_path: + if self.override_toolchain: + # We'll use MakeArgs() to provide this + pass + elif full_path: env['CROSS_COMPILE'] = wrapper + os.path.join(self.path, self.cross) else: env['CROSS_COMPILE'] = wrapper + self.cross
@@ -164,6 +176,22 @@ class Toolchain: return env + def MakeArgs(self): + """Create the 'make' arguments for a toolchain + + This is only used when the toolchain is being overridden. Since the + U-Boot Makefile sets CC and HOSTCC explicitly we cannot rely on the + environment (and MakeEnvironment()) to override these values. This + function returns the arguments to accomplish this. + + Returns: + List of arguments to pass to 'make' + """ + if self.override_toolchain: + return ['HOSTCC=%s' % self.override_toolchain, + 'CC=%s' % self.override_toolchain] + return [] + class Toolchains: """Manage a list of toolchains for building U-Boot
@@ -180,10 +208,11 @@ class Toolchains: paths: List of paths to check for toolchains (may contain wildcards) """ - def __init__(self): + def __init__(self, override_toolchain=None): self.toolchains = {} self.prefixes = {} self.paths = [] + self.override_toolchain = override_toolchain self._make_flags = dict(bsettings.GetItems('make-flags')) def GetPathList(self, show_warning=True):
@@ -234,7 +263,8 @@ class Toolchains: priority: Priority to use for this toolchain arch: Toolchain architecture, or None if not known """ - toolchain = Toolchain(fname, test, verbose, priority, arch) + toolchain = Toolchain(fname, test, verbose, priority, arch, + self.override_toolchain) add_it = toolchain.ok if toolchain.arch in self.toolchains: add_it = (toolchain.priority <
Signature · 1 line
2.20.1.97.g81188d93c3-goog
PATCH v2 3/7 buildman: Add support for building with clang
Add a -O option which allows building with clang.
---
Changes in v2:
- Use the command line instead of environment for make variables
tools/buildman/README | 10 +++++++++ tools/buildman/builderthread.py | 1 + tools/buildman/cmdline.py | 2 ++ tools/buildman/control.py | 2 +- tools/buildman/toolchain.py | 38 +++++++++++++++++++++++++++++---- 5 files changed, 48 insertions(+), 5 deletions(-)
Applied to u-boot-dm
PATCH v2 4/7 travis: Use buildman for building with clang
In reply to Simon GlassNow that buildman supports clang, use it.
---
Changes in v2: None
.travis.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
.travis.yml +3 -10
@@ -109,16 +109,9 @@ script: # # From buildman, exit code 129 means warnings only. If we've been asked to # use clang only do one configuration. - - if [[ "${TOOLCHAIN}" == "clang" ]]; then + - if [[ "${BUILDMAN}" != "" ]]; then ret=0; - make O=../.bm-work/${TEST_PY_BD} HOSTCC=clang-7 CC=clang-7 -j$(nproc) - KCFLAGS=-Werror sandbox_config all || ret=$?; - if [[ $ret -ne 0 ]]; then - exit $ret; - fi; - elif [[ "${BUILDMAN}" != "" ]]; then - ret=0; - tools/buildman/buildman -P -E ${BUILDMAN} || ret=$?; + tools/buildman/buildman -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?; if [[ $ret -ne 0 && $ret -ne 129 ]]; then tools/buildman/buildman -sdeP ${BUILDMAN}; exit $ret;
@@ -351,7 +344,7 @@ matrix: env: - TEST_PY_BD="sandbox" BUILDMAN="^sandbox$" - TOOLCHAIN="clang" + OVERRIDE="clang-7" - name: "test/py sandbox_spl" env: - TEST_PY_BD="sandbox_spl"
Signature · 1 line
2.20.1.97.g81188d93c3-goog
PATCH v2 4/7 travis: Use buildman for building with clang
Now that buildman supports clang, use it.
---
Changes in v2: None
.travis.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
Applied to u-boot-dm
PATCH v2 5/7 net: Fix error handling in sb_eth_raw_ofdata_to_platdata()
In reply to Simon GlassAt present this stores the error number in an unsigned int so an error is never detected. Use the existing signed variable instead.
---
Changes in v2: None
drivers/net/sandbox-raw.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/sandbox-raw.c +4 -5
@@ -152,7 +152,6 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev)struct eth_pdata *pdata =dev_get_platdata (dev);struct eth_sandbox_raw_priv *priv =dev_get_priv (dev);const char *ifname; -u32 local;int ret; pdata->iobase =dev_read_addr (dev);
@@ -173,10 +172,10 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev) priv->host_ifindex, priv->host_ifname); } - local =sandbox_eth_raw_os_is_local (priv->host_ifname); -if (local <0 ) -return local; - priv->local = local; + ret =sandbox_eth_raw_os_is_local (priv->host_ifname); +if (ret <0 ) +return ret; + priv->local = ret;return 0 ; }
Signature · 1 line
2.20.1.97.g81188d93c3-goog
PATCH v2 5/7 net: Fix error handling in sb_eth_raw_ofdata_to_platdata()
Quoted 5 lines · Simon Glass
At present this stores the error number in an unsigned int so an error is never detected. Use the existing signed variable instead.
Signed-off-by Simon Glass <[email protected]>
PATCH v2 5/7 net: Fix error handling in sb_eth_raw_ofdata_to_platdata()
Quoted 5 lines · Simon Glass
At present this stores the error number in an unsigned int so an error is never detected. Use the existing signed variable instead.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot-dm
PATCH v2 6/7 buildman: Write the environment out to an 'env' file
In reply to Simon GlassSometimes it is useful to see the environment that was used to build U-Boot. Write this out to a file in the build directory.
---
Changes in v2: None
tools/buildman/builderthread.py | 3 +++ 1 file changed, 3 insertions(+)
tools/buildman/builderthread.py +3 -0
@@ -322,6 +322,9 @@ class BuilderThread(threading.Thread): # Write out the image and function size information and an objdump env = result.toolchain.MakeEnvironment(self.builder.full_path) + with open(os.path.join(build_dir, 'env'), 'w') as fd: + for var in sorted(env.keys()): + print >>fd, '%s="%s"' % (var, env[var]) lines = [] for fname in ['u-boot', 'spl/u-boot-spl']: cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname]
Signature · 1 line
2.20.1.97.g81188d93c3-goog
PATCH v2 6/7 buildman: Write the environment out to an 'env' file
Sometimes it is useful to see the environment that was used to build U-Boot. Write this out to a file in the build directory.
---
Changes in v2: None
tools/buildman/builderthread.py | 3 +++ 1 file changed, 3 insertions(+)
Applied to u-boot-dm, thanks!
PATCH v2 7/7 buildman: Fix tabs in GetWrapper()
In reply to Simon GlassThis function has tabs instead of spaces. Fix it.
---
Changes in v2:
- Drop patches previously applied
- Add fixes needed to get clang building running
tools/buildman/toolchain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/buildman/toolchain.py +2 -2
@@ -135,8 +135,8 @@ class Toolchain: def GetWrapper(self, show_warning=True): """Get toolchain wrapper from the setting file. """ - value = '' - for name, value in bsettings.GetItems('toolchain-wrapper'): + value = '' + for name, value in bsettings.GetItems('toolchain-wrapper'): if not value: print "Warning: Wrapper not found" if value:
Signature · 1 line
2.20.1.97.g81188d93c3-goog
PATCH v2 7/7 buildman: Fix tabs in GetWrapper()
This function has tabs instead of spaces. Fix it.
---
Changes in v2:
- Drop patches previously applied
- Add fixes needed to get clang building running
tools/buildman/toolchain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm