Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp263562iob; Thu, 28 Apr 2022 01:39:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3vTBpIFBOLltYeBgdthvLDMLz2eCUc5hjsUIifqBRWf7pDo4sy4KFTIAF4i0NCwHfGNHn X-Received: by 2002:a17:902:8c81:b0:156:7fee:643b with SMTP id t1-20020a1709028c8100b001567fee643bmr32725258plo.59.1651135147202; Thu, 28 Apr 2022 01:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651135147; cv=none; d=google.com; s=arc-20160816; b=g533hCr+cAD8d0YNtqyUbCHC2gL2ctIVlKkZ2aSJZA34AqIr425I7mTLgVSQuP1zmM eSa2n7asPGgQGux/yXfCnJVpOR+2WBeUKS1KwXhJmjkydAq91gt7yQ6/QVeSQHjfaYBQ see1dj1Osi0kKGOV9XHK7CQLfY/Sfg2m4YmqWXt95PCoklcRkvNrmtydLK2CUOrsy07w jgo7WIahfL4bXTqcvTCRl6V8XMf8UqBf9+O2EtbxPtzIGfOJ754fMIoaitfEbmG6afej E23y2JJdZthTdjtB3hCbJmgEn6J7bT94IsZ0mMjqhkzYADkYba7BytsesEVtE2ZSsGPB S1gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=FT8JqSB1n0v5z9OANQO4H9r1qHP0NLtE2k0/+JK1Z4A=; b=zweiv/yfGljR4PvBVr1f7QHbQKDU/c0Z5sdZXq1iafIb0HPcxQNG3yNFx7oIJ7DLRx 8X2koFaRTAWMUt5X3UfZqVO6eG0sCc+iLKKa/yDTT7WwgSmVJqqY4YSp34iS0YWDzGda RG3GlpjXaH6Vbz33yUE26j9UGl+3OO2QaSAvW5G8UsDdizLpVXa9JHIxYTPaE5hT4mHf zrqr87ZqGfNXj2IWEdjS4lz51BzSu3QJXr3lM8ZWSdqh9fpokLPKpsZlnJINiDInh90Q 3Ozpic059ASO8gYMNMgu6ZN4LV74SVY5lvqtS/R8Syktux9Prm7zo8ozHMtdCLJwYPZV a4PA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y5-20020a17090322c500b0015d1a662ad2si3966178plg.241.2022.04.28.01.38.52; Thu, 28 Apr 2022 01:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242785AbiD1EwF (ORCPT + 99 others); Thu, 28 Apr 2022 00:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241731AbiD1EwC (ORCPT ); Thu, 28 Apr 2022 00:52:02 -0400 X-Greylist: delayed 587 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 27 Apr 2022 21:48:48 PDT Received: from ozlabs.ru (ozlabs.ru [107.174.27.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 666127DE21 for ; Wed, 27 Apr 2022 21:48:48 -0700 (PDT) Received: from fstn1-p1.ozlabs.ibm.com. (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id C92C980536; Thu, 28 Apr 2022 00:38:56 -0400 (EDT) From: Alexey Kardashevskiy To: linux-kernel@vger.kernel.org Cc: Alexey Kardashevskiy , Tom Rix , Nick Terrell , Nick Desaulniers , Nathan Chancellor , Masahiro Yamada Subject: [PATCH kernel] RFC: zstd: Fixing mixed module-builtin objects Date: Thu, 28 Apr 2022 14:38:50 +1000 Message-Id: <20220428043850.1706973-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With CONFIG_ZSTD_COMPRESS=m and CONFIG_ZSTD_DECOMPRESS=y we end up in a situation when files from lib/zstd/common/ are compiled once for ZSTD_DECOMPRESS (build-in) and ZSTD_COMPRESS (module) even though CFLAGS are different for builtins and modules. So far somehow this was not a problem until enabling LLVM LTO where it fails: ld.lld: error: linking module flags 'Code Model': IDs have conflicting values in 'lib/built-in.a(zstd_common.o at 5868)' and 'ld-temp.o' This particular conflict is caused by KBUILD_CFLAGS=-mcmodel=medium vs. KBUILD_CFLAGS_MODULE=-mcmodel=large , modules use the large model on POWERPC as explained at https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/Makefile?h=v5.18-rc4#n127 but the current use of common files is wrong anyway. This works around the issue by inlining common files and fixing few conflicts. Cc: Masahiro Yamada Signed-off-by: Alexey Kardashevskiy --- I tried fixing it by hacking Makefile to produce a separate .o for "y" and "m", like this: +obj-common-y = common/debug-y.o \ + common/entropy_common-y.o \ + common/error_private-y.o \ + common/fse_decompress-y.o \ + common/zstd_common-y.o +obj-common-m = common/debug-m.o \ + common/entropy_common-m.o \ + common/error_private-m.o \ + common/fse_decompress-m.o \ + common/zstd_common-m.o +obj-common-m := $(addprefix $(obj)/, $(obj-common-m)) +obj-common-y := $(addprefix $(obj)/, $(obj-common-y)) + +$(obj-common-m): $(obj)/%-m.o: %.c FORCE + $(call if_changed_dep,cc_o_c) +$(obj-common-y): $(obj)/%-y.o: %.c FORCE + $(call if_changed_dep,cc_o_c) + and so on but could not make it work and I suspect there is a better solution to the problem anyway, what is it? --- lib/zstd/Makefile | 10 ---------- lib/zstd/common/error_private.h | 2 +- lib/zstd/common/entropy_common.c | 4 ++-- lib/zstd/zstd_compress_module.c | 6 ++++++ lib/zstd/zstd_decompress_module.c | 6 ++++++ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/zstd/Makefile b/lib/zstd/Makefile index fc45339fc3a3..ee42f07711ea 100644 --- a/lib/zstd/Makefile +++ b/lib/zstd/Makefile @@ -13,11 +13,6 @@ obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd_decompress.o zstd_compress-y := \ zstd_compress_module.o \ - common/debug.o \ - common/entropy_common.o \ - common/error_private.o \ - common/fse_decompress.o \ - common/zstd_common.o \ compress/fse_compress.o \ compress/hist.o \ compress/huf_compress.o \ @@ -33,11 +28,6 @@ zstd_compress-y := \ zstd_decompress-y := \ zstd_decompress_module.o \ - common/debug.o \ - common/entropy_common.o \ - common/error_private.o \ - common/fse_decompress.o \ - common/zstd_common.o \ decompress/huf_decompress.o \ decompress/zstd_ddict.o \ decompress/zstd_decompress.o \ diff --git a/lib/zstd/common/error_private.h b/lib/zstd/common/error_private.h index d14e686adf95..e1570545c6af 100644 --- a/lib/zstd/common/error_private.h +++ b/lib/zstd/common/error_private.h @@ -42,7 +42,7 @@ typedef ZSTD_ErrorCode ERR_enum; #define ERROR(name) ZSTD_ERROR(name) #define ZSTD_ERROR(name) ((size_t)-PREFIX(name)) -ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); } +ERR_STATIC inline unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); } ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); } diff --git a/lib/zstd/common/entropy_common.c b/lib/zstd/common/entropy_common.c index 53b47a2b52ff..863afecb7743 100644 --- a/lib/zstd/common/entropy_common.c +++ b/lib/zstd/common/entropy_common.c @@ -28,10 +28,10 @@ unsigned FSE_versionNumber(void) { return FSE_VERSION_NUMBER; } /*=== Error Management ===*/ -unsigned FSE_isError(size_t code) { return ERR_isError(code); } +#define FSE_isError ERR_isError const char* FSE_getErrorName(size_t code) { return ERR_getErrorName(code); } -unsigned HUF_isError(size_t code) { return ERR_isError(code); } +#define HUF_isError ERR_isError const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); } diff --git a/lib/zstd/zstd_compress_module.c b/lib/zstd/zstd_compress_module.c index 65548a4bb934..a4ad46fc1f12 100644 --- a/lib/zstd/zstd_compress_module.c +++ b/lib/zstd/zstd_compress_module.c @@ -158,3 +158,9 @@ EXPORT_SYMBOL(zstd_end_stream); MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("Zstd Compressor"); + +#include "common/debug.c" +#include "common/entropy_common.c" +#include "common/error_private.c" +#include "common/fse_decompress.c" +#include "common/zstd_common.c" diff --git a/lib/zstd/zstd_decompress_module.c b/lib/zstd/zstd_decompress_module.c index f4ed952ed485..21820588835d 100644 --- a/lib/zstd/zstd_decompress_module.c +++ b/lib/zstd/zstd_decompress_module.c @@ -103,3 +103,9 @@ EXPORT_SYMBOL(zstd_get_frame_header); MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("Zstd Decompressor"); + +#include "common/debug.c" +#include "common/entropy_common.c" +#include "common/error_private.c" +#include "common/fse_decompress.c" +#include "common/zstd_common.c" -- 2.30.2