From patchwork Thu Aug 4 12:04:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1663645 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=JUXU0UP5; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=dij7lkc5; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lz6qg21v0z9sFs for ; Thu, 4 Aug 2022 22:05:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Df6ZBe1RYZFtHavFgNXmgsu1NCzi+CoI8oqFI8Xl54w=; b=JUXU0UP5D57xs4 6sEgYUOMBhNtBhLKdtBO2DnLhdDG3t08CnYB2BtpJHFiRnd5WnX7U1SvYgIj6VromYzRvwtPpvhFo vEenQb03nP+Cw2+Eft3fJYALUzRn55D8RHFLHZMpwOOLgcqIJVDC7tvRlPQPYt30GYIBvxKAtEWw1 bnXnp+yA/pfXVQ5lRSbGXDAuN81JCvL1DWOAD0yeOaODlQ51009qPXq1DsmZs4ocNqNOHGMFScgPV 7HOy0Rkon9RI7qLgQtfrJMVdap1n2zetJd9Yz8iyJsq5pdpok7NI7dlT6g6fdGcYbykxScFvzDDRX bxtFpf/Jz5vjL1QxDULg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJZb7-005mez-Sz; Thu, 04 Aug 2022 12:05:05 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJZb5-005mcL-O7 for opensbi@lists.infradead.org; Thu, 04 Aug 2022 12:05:05 +0000 Received: by mail-oi1-x22d.google.com with SMTP id v203so2308364oie.10 for ; Thu, 04 Aug 2022 05:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=c7GZZo3UWYBFGIQfWPsYuj0/LwvFQMyZdaNrandOtSo=; b=dij7lkc5BLcDvBHg5+axQ3K5EMsj60yANDxLSSuw8Pbh5JcviGqKhcwlhNLHUJV1De BUDihZOvo9ktzcf5Lqp5LuqG+vmWy7YUo0B6Jmc410/f+rcY/aGOH5LrtSITuZ/Ez3q7 TV7ouyDNw+fDyOei64l6pFFsdOmJ2MvDYCArvgmQWH/wUUvP7b7YVaP6aVVbM+pmCX+V dss7GzTv1BtvjlhnMYEqmoM4EBJMmD9NVmmskprqybxEHpqBA6MwnHERSJzrjhQpo2tG wkXlWfUJM7odG00LM0+HFmxZlbbmC2Wvj9ka+9OcCHF3y07HISw/Cld0EZay8ocAGv0T iCWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=c7GZZo3UWYBFGIQfWPsYuj0/LwvFQMyZdaNrandOtSo=; b=FafSNjw4OR6IGLc6GQmtzDRpEOtdRskl51H8YZ6hkUUq2cyqGG043Qu4cGdfEVt3EM 7lX1wVwzbqLFgYPc14Qyj/jINr1P2Dcjn4INGPl7hn49P3gTM17wBjvfrD+rYnVWTui4 94OwkNtU8otmCHiodT/YqroHGZSl61wj8M54n3G+0hVWNqIfrhKlzMVzSMGRtCgLZiQu JqfuZdKXvCmlLqSHbtJipVUGNC/bm6CeBha8YeZZkq2dFB4M3pe4vzEFWP2IkgwOpX4t WxyCx24Uyf00T27ot203NzxSWILZYh16mEagLe6m7XE6GvUXSdywGuUESsyTL1sIk2Ei 1e4g== X-Gm-Message-State: ACgBeo3MPwprnUDIsTSH7yHXHMsXjqbpmP5YVPfqFq1N4bgwOhXBGHgO KyLUpF9WCB6CyszkgSHXCyrcgw== X-Google-Smtp-Source: AA6agR7eNAIzg+mLNI+XhqpMhg6xUnMkAPc9j8NUkQFyw0sEZeHzUnF2FI4Wm0RFH81AkUtMDDLeWQ== X-Received: by 2002:a05:6808:300c:b0:33c:1ca9:30de with SMTP id ay12-20020a056808300c00b0033c1ca930demr641405oib.243.1659614701331; Thu, 04 Aug 2022 05:05:01 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id r13-20020a056871088d00b000f5f4ad194bsm93184oaq.25.2022.08.04.05.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 05:05:00 -0700 (PDT) From: Anup Patel To: Atish Patra , Alistair Francis Cc: Andrew Jones , David Abdurachmanov , Heinrich Schuchardt , Andreas Schwab , Mark Kettenis , Emmanuel Vadot , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v6 03/17] Makefile: Compile lib/utils sources separately for each platform Date: Thu, 4 Aug 2022 17:34:15 +0530 Message-Id: <20220804120429.59444-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220804120429.59444-1-apatel@ventanamicro.com> References: <20220804120429.59444-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220804_050503_825615_D50A76C9 X-CRM114-Status: GOOD ( 12.82 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Currently, if same build directory is used to compile two different platforms then lib/utils objects are shared for these platforms. We will be having platform specific configs to enable/disable drivers in lib/utils and select compile time options for lib/utils sources. This means lib/utils sources will now be compiled in a platfor [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:22d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently, if same build directory is used to compile two different platforms then lib/utils objects are shared for these platforms. We will be having platform specific configs to enable/disable drivers in lib/utils and select compile time options for lib/utils sources. This means lib/utils sources will now be compiled in a platform specific way. To tackle above, we update top-level Makefile as follows: 1) Don't create libsbiutils.a anymore because this can't be shared between platforms. 2) Compile lib/utils sources separately for each platform. 3) Add comments showing which make rules are for lib/sbi, lib/utils, firmware, and platform sources. Signed-off-by: Anup Patel Tested-by: Andrew Jones --- Makefile | 48 ++++++++++++++++---------------- docs/library_usage.md | 6 +--- scripts/create-binary-archive.sh | 2 +- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 677ea83..678159c 100644 --- a/Makefile +++ b/Makefile @@ -243,8 +243,8 @@ include $(firmware-object-mks) # Setup list of objects libsbi-objs-path-y=$(foreach obj,$(libsbi-objs-y),$(build_dir)/lib/sbi/$(obj)) -libsbiutils-objs-path-y=$(foreach obj,$(libsbiutils-objs-y),$(build_dir)/lib/utils/$(obj)) ifdef PLATFORM +libsbiutils-objs-path-y=$(foreach obj,$(libsbiutils-objs-y),$(platform_build_dir)/lib/utils/$(obj)) platform-objs-path-y=$(foreach obj,$(platform-objs-y),$(platform_build_dir)/$(obj)) firmware-bins-path-y=$(foreach bin,$(firmware-bins-y),$(platform_build_dir)/firmware/$(bin)) endif @@ -461,7 +461,6 @@ compile_gen_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \ echo "$(1:.dep=$(2)): $(3)" >> $(1) targets-y = $(build_dir)/lib/libsbi.a -targets-y += $(build_dir)/lib/libsbiutils.a ifdef PLATFORM targets-y += $(platform_build_dir)/lib/libplatsbi.a endif @@ -474,12 +473,10 @@ all: $(targets-y) # Preserve all intermediate files .SECONDARY: +# Rules for lib/sbi sources $(build_dir)/lib/libsbi.a: $(libsbi-objs-path-y) $(call compile_ar,$@,$^) -$(build_dir)/lib/libsbiutils.a: $(libsbi-objs-path-y) $(libsbiutils-objs-path-y) - $(call compile_ar,$@,$^) - $(platform_build_dir)/lib/libplatsbi.a: $(libsbi-objs-path-y) $(libsbiutils-objs-path-y) $(platform-objs-path-y) $(call compile_ar,$@,$^) @@ -503,22 +500,14 @@ $(build_dir)/%.dep: $(src_dir)/%.S $(build_dir)/%.o: $(src_dir)/%.S $(call compile_as,$@,$<) -$(build_dir)/%.dep: $(src_dir)/%.carray +# Rules for platform sources +$(platform_build_dir)/%.dep: $(platform_src_dir)/%.carray $(call compile_gen_dep,$@,.c,$< $(KCONFIG_CONFIG)) $(call compile_gen_dep,$@,.o,$(@:.dep=.c)) -$(build_dir)/%.c: $(src_dir)/%.carray +$(platform_build_dir)/%.c: $(platform_src_dir)/%.carray $(call compile_carray,$@,$<) -$(platform_build_dir)/%.bin: $(platform_build_dir)/%.elf - $(call compile_objcopy,$@,$<) - -$(platform_build_dir)/%.elf: $(platform_build_dir)/%.o $(platform_build_dir)/%.elf.ld $(platform_build_dir)/lib/libplatsbi.a - $(call compile_elf,$@,$@.ld,$< $(platform_build_dir)/lib/libplatsbi.a) - -$(platform_build_dir)/%.ld: $(src_dir)/%.ldS - $(call compile_cpp,$@,$<) - $(platform_build_dir)/%.dep: $(platform_src_dir)/%.c $(call compile_cc_dep,$@,$<) @@ -542,6 +531,23 @@ $(platform_build_dir)/%.c: $(platform_build_dir)/%.dtb $(platform_build_dir)/%.dtb: $(platform_src_dir)/%.dts $(call compile_dts,$@,$<) +# Rules for lib/utils and firmware sources +$(platform_build_dir)/%.bin: $(platform_build_dir)/%.elf + $(call compile_objcopy,$@,$<) + +$(platform_build_dir)/%.elf: $(platform_build_dir)/%.o $(platform_build_dir)/%.elf.ld $(platform_build_dir)/lib/libplatsbi.a + $(call compile_elf,$@,$@.ld,$< $(platform_build_dir)/lib/libplatsbi.a) + +$(platform_build_dir)/%.ld: $(src_dir)/%.ldS + $(call compile_cpp,$@,$<) + +$(platform_build_dir)/%.dep: $(src_dir)/%.carray + $(call compile_gen_dep,$@,.c,$< $(KCONFIG_CONFIG)) + $(call compile_gen_dep,$@,.o,$(@:.dep=.c)) + +$(platform_build_dir)/%.c: $(src_dir)/%.carray + $(call compile_carray,$@,$<) + $(platform_build_dir)/%.dep: $(src_dir)/%.c $(call compile_cc_dep,$@,$<) @@ -595,7 +601,6 @@ endif endif install_targets-y = install_libsbi -install_targets-y += install_libsbiutils ifdef PLATFORM install_targets-y += install_libplatsbi install_targets-y += install_firmwares @@ -610,17 +615,12 @@ install_libsbi: $(build_dir)/lib/libsbi.a $(call inst_header_dir,$(install_root_dir)/$(install_include_path),$(include_dir)/sbi) $(call inst_file,$(install_root_dir)/$(install_lib_path)/libsbi.a,$(build_dir)/lib/libsbi.a) -.PHONY: install_libsbiutils -install_libsbiutils: $(build_dir)/lib/libsbiutils.a - $(call inst_header_dir,$(install_root_dir)/$(install_include_path),$(include_dir)/sbi_utils) - $(call inst_file,$(install_root_dir)/$(install_lib_path)/libsbiutils.a,$(build_dir)/lib/libsbiutils.a) - .PHONY: install_libplatsbi -install_libplatsbi: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsbi.a $(build_dir)/lib/libsbiutils.a +install_libplatsbi: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsbi.a $(call inst_file,$(install_root_dir)/$(install_lib_path)/opensbi/$(platform_subdir)/lib/libplatsbi.a,$(platform_build_dir)/lib/libplatsbi.a) .PHONY: install_firmwares -install_firmwares: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsbi.a $(build_dir)/lib/libsbiutils.a $(firmware-bins-path-y) +install_firmwares: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsbi.a $(firmware-bins-path-y) $(call inst_file_list,$(install_root_dir),$(build_dir),$(install_firmware_path)/$(platform_subdir)/firmware,$(firmware-elfs-path-y)) $(call inst_file_list,$(install_root_dir),$(build_dir),$(install_firmware_path)/$(platform_subdir)/firmware,$(firmware-bins-path-y)) diff --git a/docs/library_usage.md b/docs/library_usage.md index ff99801..d5d2ba9 100644 --- a/docs/library_usage.md +++ b/docs/library_usage.md @@ -8,11 +8,7 @@ OpenSBI provides two types of static libraries: hooks for the execution of this interface must be provided by the firmware or bootloader linking with this library. This library is installed as */lib/libsbi.a* -2. *libsbiutils.a* - A static library that will contain all common code required - by any platform supported in OpenSBI. It will be built by default and included - in libplatsbi.a. This library is installed as - */lib/libsbiutils.a*. -3. *libplatsbi.a* - An example platform-specific static library integrating +2. *libplatsbi.a* - An example platform-specific static library integrating *libsbi.a* with platform-specific hooks. This library is available only for the platforms supported by OpenSBI. This library is installed as */platform//lib/libplatsbi.a* diff --git a/scripts/create-binary-archive.sh b/scripts/create-binary-archive.sh index 43c5452..261a45a 100755 --- a/scripts/create-binary-archive.sh +++ b/scripts/create-binary-archive.sh @@ -118,7 +118,7 @@ build_opensbi() { # Build and install generic library echo "Build and install generic library XLEN=${BUILD_RISCV_XLEN}" echo "" - make -C "${BUILD_OPENSBI_SOURCE_PATH}" O="${BUILD_OUTPUT_PATH}/${BUILD_NAME}" I="${BUILD_OUTPUT_PATH}/${BUILD_ARCHIVE_NAME}" PLATFORM_RISCV_XLEN="${BUILD_RISCV_XLEN}" install_libsbi install_libsbiutils -j "${BUILD_NUM_THREADS}" + make -C "${BUILD_OPENSBI_SOURCE_PATH}" O="${BUILD_OUTPUT_PATH}/${BUILD_NAME}" I="${BUILD_OUTPUT_PATH}/${BUILD_ARCHIVE_NAME}" PLATFORM_RISCV_XLEN="${BUILD_RISCV_XLEN}" install_libsbi -j "${BUILD_NUM_THREADS}" echo "" # Build and install relevant platforms