Linux-Sparse Archive mirror
 help / color / mirror / Atom feed
From: Yuan Tan <tanyuan@tinylab.org>
To: i@maskray.me
Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org,
	linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org,
	linux-sparse@vger.kernel.org, linux@weissschuh.net,
	luc.vanoostenryck@gmail.com, palmer@rivosinc.com,
	paul.walmsley@sifive.com, paulburton@kernel.org,
	paulmck@kernel.org, tanyuan@tinylab.org, tim.bird@sony.com,
	tsbogend@alpha.franken.de, w@1wt.eu
Subject: Re: [PATCH v1 09/14] DCE/DSE: inhibit .size directive for SHF_GROUP
Date: Mon, 13 Nov 2023 15:19:42 +0800	[thread overview]
Message-ID: <20231113071942.35259-1-tanyuan@tinylab.org> (raw)
In-Reply-To: <DS7PR12MB576503711253C682DCE40524CBABA@DS7PR12MB5765.namprd12.prod.outlook.com>

Hi, Fangrui

Thank you for your time :)

On 11/6/2023 4:50 AM, Fangrui Song wrote:
> On Fri, Nov 3, 2023 at 9:01 AM Yuan Tan <tanyuan@tinylab.org> wrote:
> >
> > .size directive fails in some functions with SHF_GROUP, this is not
> > really required for normal building, inhibit it to silence the compiling
> > failures with SHF_GROUP.
> >
> > Signed-off-by: Yuan Tan <tanyuan@tinylab.org>
> > Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
> > ---
> >  Makefile | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/Makefile b/Makefile
> > index a4e522b747cb..f67b6e8d2c45 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -936,6 +936,9 @@ endif
> >  # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
> >  ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
> >  KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
> > +ifdef CONFIG_SECTION_SHF_GROUP_SUPPORT
> > +KBUILD_CFLAGS_KERNEL += -finhibit-size-directive
> > +endif
> >  KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
> >  LDFLAGS_vmlinux += --gc-sections
> >  ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION_DEBUG
> > --
> > 2.34.1
> >
> 
> Clang doesn't support -finhibit-size-directive, so this would break
> Clang builds.

Currently, Clang doesn't support LD_DEAD_CODE_DATA_ELIMINATION. So in this
patch series I didn't take much thought about clang.

> 
> GCC has had this option since 1992, but it is not used in the wild.
> https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-finhibit-size-directive
> says
> 
> > ... This option is used when compiling crtstuff.c; you should not need to use it for anything else.
> 
> What problem have you seen with .size directives (st_size field in
> symbol table entries)?

$ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- fs/ioctl.o
/tmp/ccy5E3wN.s: Error: .size expression for __riscv_sys_ioctl does not evaluate to a constant
make[3]: *** [scripts/Makefile.build:243: fs/ioctl.o] Error 1
make[2]: *** [scripts/Makefile.build:480: fs] Error 2
make[1]: *** [/home/tanyuan/projects/linux/Makefile:1916: .] Error 2
make: *** [Makefile:234: __sub-make] Error 2

And the fs/ioctl.s is like
	.section	.text.__riscv_sys_ioctl,"ax",@progbits
	.align	1
	.globl	__riscv_sys_ioctl
	.type	__riscv_sys_ioctl, @function
__riscv_sys_ioctl:
        ...
        ...
	.size	__riscv_sys_ioctl, .-__riscv_sys_ioctl

I cannot understand this error and this option just solve the problem :)

> 
> % cat a.c
> int v;
> void f() {}
> % diff -u0 <(gcc -S a.c -o -) <(gcc -S -finhibit-size-directive a.c -o -)
> --- /proc/self/fd/11    2023-11-05 12:42:51.298618475 -0800
> +++ /proc/self/fd/15    2023-11-05 12:42:51.298618475 -0800
> @@ -7 +6,0 @@
> -       .size   v, 4
> @@ -27 +25,0 @@
> -       .size   f, .-f
> 
> 

  reply	other threads:[~2023-11-13  7:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 15:56 [PATCH v1 00/14] DCE/DSE: Add Dead Syscalls Elimination support, part2 Yuan Tan
2023-11-03 15:58 ` [PATCH v1 01/14] DCE/DSE: allow keep unique bounded sections Yuan Tan
2023-11-03 15:58 ` [PATCH v1 02/14] compiler: add a global __QUITE_UNIQUE_ID() Yuan Tan
2023-11-03 15:58 ` [PATCH v1 03/14] compiler: add unique __SECTION_NAME() Yuan Tan
2023-11-03 15:59 ` [PATCH v1 04/14] compiler: add unique LABEL_NAME() Yuan Tan
2023-11-03 15:59 ` [PATCH v1 05/14] DCE/DSE: add HAVE_SECTION_SHF_LINK_ORDER_SUPPORT option Yuan Tan
2023-11-03 16:00 ` [PATCH v1 06/14] DCE/DSE: add HAVE_SECTION_SHF_GROUP_SUPPORT option Yuan Tan
2023-11-03 16:00 ` [PATCH v1 07/14] DCE/DSE: add HAVE_SECTION_NO_KEEP_SUPPORT option Yuan Tan
2023-11-03 16:00   ` Yuan Tan
2023-11-03 16:01 ` [PATCH v1 08/14] DCE/DSE: add choice of methods to build reference for orphan sections Yuan Tan
2023-11-05 21:35   ` Fangrui Song
2023-11-03 16:01 ` [PATCH v1 09/14] DCE/DSE: inhibit .size directive for SHF_GROUP Yuan Tan
2023-11-05 20:50   ` Fangrui Song
2023-11-13  7:19     ` Yuan Tan [this message]
2023-11-03 16:02 ` [PATCH v1 10/14] DCE/DSE: riscv: make every ex_table's name unique Yuan Tan
2023-11-03 16:02   ` Yuan Tan
2023-11-05 21:13   ` Fangrui Song
2023-11-03 16:02 ` [PATCH v1 11/14] DCE/DSE: riscv: build reference for .pushsection in C functions Yuan Tan
2023-11-03 16:03 ` [PATCH v1 12/14] DCE/DSE: riscv: build reference for .pushsection in assembly Yuan Tan
2023-11-03 16:04 ` [PATCH v1 13/14] DCE/DSE: add SECTION_NO_KEEP_SUPPORT option Yuan Tan
2023-11-03 16:04 ` [PATCH v1 14/14] DCE/DSE: vmlinux.lds.h: allow NO_KEEP on __ex_table sections Yuan Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231113071942.35259-1-tanyuan@tinylab.org \
    --to=tanyuan@tinylab.org \
    --cc=arnd@arndb.de \
    --cc=falcon@tinylab.org \
    --cc=i@maskray.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=palmer@rivosinc.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paulburton@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=tim.bird@sony.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=w@1wt.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).