From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=kMiWmP5n; spf=pass (domain: linaro.org, ip: 209.85.221.66, mailfrom: leif.lindholm@linaro.org) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by groups.io with SMTP; Tue, 17 Sep 2019 06:08:58 -0700 Received: by mail-wr1-f66.google.com with SMTP id i18so3050864wru.11 for ; Tue, 17 Sep 2019 06:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rTc3kKKNoU8lyUqtj1ey3HVw66BYQQEeUGzQiiZFI1w=; b=kMiWmP5naD6LAWco/VNZfTqxSp9W08gy3K7TWr7vxoGaWdglWNnuvKTKFdRsplbBwG 7juEMDF4JiG7TVLSqA2P0VrIbMK8EcOOSaqu9Qv+7KciMt83WL8AJcyRIAtqbLdNq/iv RIsrnehSmXHIV7Oc1DxZabUR5/ATYJfvcldMTsO7BFEjZyawvpEgkaLMPfZs6AYSxck6 gdsgR6Bx3iCvVBMLenpyHHWFSFWCpHPGt2lt99JOvG1e58AVOX6KDZLy76XAWh5Xn0yo +/YTTQTNVUAFlNVDY437dpMzL+a7mPhpHeZETihLq+q8GAlsvm0KA2q5eKjQMT6DvAwV ELaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rTc3kKKNoU8lyUqtj1ey3HVw66BYQQEeUGzQiiZFI1w=; b=tK2MFePxDy3kFjjZoPSZbyGO4JKOBmxIxvQ2TBTGtSE2v/SEuvcxTm0SC/BJNvuFll xWIUjbAwdBdXrkMBrJIjIWfaijBPW0gZUuKCkyW/giOy7Dlkg/y2vuAkVKJhqahNvcfe MkUVmUM+O/0NtB5QlHv/42AXQj2u1ZGrApzS7ptVHzoZncDm/S7Fw9b7jjeOgY3925lD p2nYjOJVPnZeqnytbSsMEY2N7VKsvE6xVr+yn8eJJ9jKx1vc5dL5CuDfDItqXSgtbptx uUpdfufLwDGi7zP/rxmZ2AYzKjOokwrVmPnUOkmuFIWB20UWdUA5wYXBpuDaDL1PTxD1 V9TA== X-Gm-Message-State: APjAAAVFHXs9KxT/NL0OCk/jxUklwUALmQAee+oysSv8TsiWWTP98Ie/ AoOcYVy2KfVIK7/lCldo/jyoclVselE= X-Google-Smtp-Source: APXvYqzxMaE4X5vwkp6KCqNQAXJg0BFnXi3g/C+6ObIrlCo5mhH8jnSHUJ5GVYiRxJVvve9tH/p3+A== X-Received: by 2002:adf:dfc2:: with SMTP id q2mr3196252wrn.307.1568725735859; Tue, 17 Sep 2019 06:08:55 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id y14sm3686526wrd.84.2019.09.17.06.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2019 06:08:54 -0700 (PDT) Date: Tue, 17 Sep 2019 14:08:53 +0100 From: "Leif Lindholm" To: devel@edk2.groups.io, abner.chang@hpe.com Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]: BaseTools: BaseTools changes for RISC-V platform. Message-ID: <20190917130853.GC28454@bivouac.eciton.net> References: <1567593797-26216-1-git-send-email-abner.chang@hpe.com> <1567593797-26216-12-git-send-email-abner.chang@hpe.com> <20190909113648.GD16218@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Sep 16, 2019 at 07:46:26AM +0000, Abner Chang wrote: > > -----Original Message----- > > From: Leif Lindholm [mailto:leif.lindholm@linaro.org] > > Sent: Monday, September 9, 2019 7:37 PM > > To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist) > > > > Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v1 11/22]: > > BaseTools: BaseTools changes for RISC-V platform. > > > > Hi Abner, > > > > Having actually tried to build things, I have come across a bunch of > > issues with this patch I missed on my (very cursory) ocular review. > > > > On Wed, Sep 04, 2019 at 06:43:06PM +0800, Abner Chang wrote: > > > BaseTools changes for building EDK2 RISC-V platform. > > > The changes made to build_rule.template is to avoid build errors cause by > > GCC711RISCV tool chain. > > > > > > Contributed-under: TianoCore Contribution Agreement 1.0 > > > Signed-off-by: Abner Chang > > > --- > > > BaseTools/Conf/build_rule.template | 23 +- > > > BaseTools/Conf/tools_def.template | 108 +- > > > BaseTools/Source/C/Common/BasePeCoff.c | 19 +- > > > BaseTools/Source/C/Common/PeCoffLoaderEx.c | 96 ++ > > > BaseTools/Source/C/GenFv/GenFvInternalLib.c | 281 ++++- > > > BaseTools/Source/C/GenFw/Elf32Convert.c | 6 +- > > > BaseTools/Source/C/GenFw/Elf64Convert.c | 273 ++++- > > > BaseTools/Source/C/GenFw/elf_common.h | 63 ++ > > > .../Source/C/Include/IndustryStandard/PeImage.h | 10 + > > > BaseTools/Source/Python/Common/DataType.py | 1075 > > ++++++++++---------- > > > 10 files changed, 1393 insertions(+), 561 deletions(-) > > > > > > diff --git a/BaseTools/Conf/tools_def.template > > b/BaseTools/Conf/tools_def.template > > > index 8f0e6cb..36a301a 100755 > > > --- a/BaseTools/Conf/tools_def.template > > > +++ b/BaseTools/Conf/tools_def.template > > > @@ -3,7 +3,7 @@ > > > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > > # Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
> > > # Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
> > > -# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> > > +# (C) Copyright 2016-2019 Hewlett Packard Enterprise Development > > LP
> > > # > > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > # > > > @@ -114,6 +114,12 @@ DEFINE GCC49_X64_PREFIX = ENV(GCC49_BIN) > > > DEFINE GCC5_IA32_PREFIX = ENV(GCC5_BIN) > > > DEFINE GCC5_X64_PREFIX = ENV(GCC5_BIN) > > > DEFINE GCC_HOST_PREFIX = ENV(GCC_HOST_BIN) > > > +# > > > +# RISC-V GCC toolchain > > > +# This is the default directory used when install official riscv-tools. > > > +# > > > +DEFINE GCCRISCV_RISCV32_PREFIX = ENV(GCC_RISCV32_BIN) > > > +DEFINE GCCRISCV_RISCV64_PREFIX = ENV(GCC_RISCV64_BIN) > > > > If at all possible, I would strongly recommend *not* following the x86 > > _BIN example, and instead using ENV(_RISCV64_PREFIX) like > > the ARM/AARCH64 profiles. > > > > > DEFINE UNIX_IASL_BIN = ENV(IASL_PREFIX)iasl > > > DEFINE WIN_IASL_BIN = ENV(IASL_PREFIX)iasl.exe > > > @@ -236,6 +242,15 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc > > > # Required to build platforms or ACPI tables: > > > # Intel(r) ACPI Compiler from > > > # https://acpica.org/downloads > > > +# GCCRISCV - Linux - Requires: > > > +# RISC-V official release of RISC-V GNU toolchain, > > > +# https://github.com/riscv/riscv-gnu-toolchain @64879b24 > > > +# The commit ID 64879b24 is the one can build RISC-V > > platform and boo to EFI shell. > > > +# Follow the instructions mentioned in README.md to > > build RISC-V tool change. > > > +# Set below environment variables to the RISC-V tool chain > > binaries before building RISC-V EDK2 port. > > > +# - GCC_RISCV32_BIN > > > +# - GCC_RISCV64_BIN > > > +# > > > # CLANG35 -Linux,Windows- Requires: > > > # Clang v3.5 or later, and GNU binutils targeting aarch64- > > linux-gnu or arm-linux-gnueabi > > > # Optional: > > > @@ -1806,6 +1821,26 @@ DEFINE GCC5_ARM_ASLDLINK_FLAGS = > > DEF(GCC49_ARM_ASLDLINK_FLAGS) > > > DEFINE GCC5_AARCH64_ASLDLINK_FLAGS = > > DEF(GCC49_AARCH64_ASLDLINK_FLAGS) > > > DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto > > > > > > +DEFINE GCC_RISCV_ALL_CC_FLAGS = -g -fshort-wchar -fno- > > strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata- > > sections -c -include AutoGen.h -fno-common - > > DSTRING_ARRAY_NAME=$(BASE_NAME)Strings > > > +DEFINE GCC_RISCV_ALL_DLINK_COMMON = -nostdlib -n -q --gc- > > sections -z common-page-size=0x40 > > > +DEFINE GCC_RISCV_ALL_DLINK_FLAGS = > > DEF(GCC_RISCV_ALL_DLINK_COMMON) --entry $(IMAGE_ENTRY_POINT) -u > > $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map > > > +DEFINE GCC_RISCV_ALL_DLINK2_FLAGS = -- > > defsym=PECOFF_HEADER_SIZE=0x220 -- > > script=$(EDK_TOOLS_PATH)/Scripts/GccBaseRiscV.lds > > > +DEFINE GCC_RISCV_ALL_ASM_FLAGS = -c -x assembler -imacros > > $(DEST_DIR_DEBUG)/AutoGen.h > > > +DEFINE GCC_RISCV_RISCV32_DLINK2_FLAGS = -- > > defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON) > > > + > > > +DEFINE GCCRISCV_RISCV32_ARCH = rv32imafdc > > > +DEFINE GCCRISCV_RISCV64_ARCH = rv64imafdc > > > +DEFINE GCCRISCV_CC_FLAGS_WARNING_DISABLE = -Wno- > > tautological-compare -Wno-pointer-compare > > > +DEFINE GCCRISCV_RISCV32_CC_FLAGS = > > DEF(GCC_RISCV_ALL_CC_FLAGS) > > DEF(GCCRISCV_CC_FLAGS_WARNING_DISABLE) - > > march=DEF(GCCRISCV_RISCV32_ARCH) -malign-double -fno-stack-protector > > -D EFI32 -fno-asynchronous-unwind-tables -Wno-address -Wno-unused-but- > > set-variable -fpack-struct=8 > > > +DEFINE GCCRISCV_RISCV64_CC_FLAGS = > > DEF(GCC_RISCV_ALL_CC_FLAGS) > > DEF(GCCRISCV_CC_FLAGS_WARNING_DISABLE) - > > march=DEF(GCCRISCV_RISCV64_ARCH) -fno-builtin -fno-builtin-memcpy - > > fno-stack-protector -Wno-address -fno-asynchronous-unwind-tables -Wno- > > unused-but-set-variable -fpack-struct=8 -mcmodel=medany -mabi=lp64 > > > +DEFINE GCCRISCV_RISCV32_RISCV64_DLINK_COMMON = -nostdlib -n -q > > --gc-sections -z common-page-size=0x40 > > > +DEFINE GCCRISCV_RISCV32_RISCV64_ASLDLINK_FLAGS = > > DEF(GCC_RISCV_ALL_DLINK_COMMON) --entry ReferenceAcpiTable -u > > ReferenceAcpiTable > > > +DEFINE GCCRISCV_RISCV32_RISCV64_DLINK_FLAGS = > > DEF(GCC_RISCV_ALL_DLINK_COMMON) --entry $(IMAGE_ENTRY_POINT) -u > > $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map > > > +DEFINE GCCRISCV_RISCV32_DLINK2_FLAGS = > > DEF(GCC_RISCV_RISCV32_DLINK2_FLAGS) > > > +DEFINE GCCRISCV_RISCV64_DLINK_FLAGS = > > DEF(GCC_RISCV_ALL_DLINK_FLAGS) -melf64lriscv --oformat=elf64-littleriscv > > --no-relax > > > +DEFINE GCCRISCV_RISCV64_DLINK2_FLAGS = > > DEF(GCC_RISCV_ALL_DLINK2_FLAGS) > > > +DEFINE GCCRISCV_ASM_FLAGS = > > DEF(GCC_RISCV_ALL_ASM_FLAGS) -march=DEF(GCCRISCV_RISCV64_ARCH) > > -mcmodel=medany -mabi=lp64 > > > + > > > > > ########################################################## > > ########################## > > > # > > > # GCC 4.8 - This configuration is used to compile under Linux to produce > > > @@ -2247,6 +2282,77 @@ RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z > > common-page-size=0x20 > > > NOOPT_GCC5_AARCH64_DLINK_FLAGS = > > DEF(GCC5_AARCH64_DLINK_FLAGS) -O0 > > > NOOPT_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 > > -O0 > > > > > > > > +######################################################### > > ########################## > > > > > +######################################################### > > ########################### > > > +# > > > +# GCC RISC-V This configuration is used to compile under Linux to produce > > > +# PE/COFF binaries using GCC RISC-V tool chain > > > +# https://github.com/riscv/riscv-gnu-toolchain @64879b24 > > > +# The commit ID 64879b24 is the one can build RISC-V platform and boo to > > EFI shell. > > > +# > > > > > +######################################################### > > ########################### > > > > Please don't do this. This mistake was made for the ARM port, and it > > caused us nothing but pain. > > > > Please add the requisite support to the GCC5 profile instead. (Which > > is not actually for gcc 5, but is effectively GCC5+ - we are still > > successfully using it with gcc 9.) > > I can try to use GCC5 profile but the toolchain still has to be > stick on https://github.com/riscv/riscv-gnu-toolchain @64879b24. We > got problem on the version higher than this, system hangs at SEC to > PEI transition if use GCC version higher than @64879b24. > > We will figure it out later. I suppose this is fine as long as this is specifically on the edk2-staging branch. We will need to resolve it before we bring the port to edk2 master. I would still like this support to be tweaked to the point where I can build with either the Fedora or the Debian packaged cross compiler. > So how can I mention this restrictions in tool_def? I would suggest the following: - The above information in the top-level Readme.md on the staging branch. - A single line in the "GCC5 RISCV64 definitions" comment block. - Adding the above to the commit message. Best Regards, Leif