Thread overview |
---|
February 27, 2021 All strings are in one section | ||||
---|---|---|---|---|
| ||||
On linux LLVM puts most things in different sections, so they can be collected with --gc-sections linker option, but all strings still go in one section, and can't be collected individually. Is there a way to put strings in different sections? --data-sections option doesn't help. |
February 27, 2021 Re: All strings are in one section | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Saturday, 27 February 2021 at 14:46:55 UTC, Kagamin wrote: > On linux LLVM puts most things in different sections, so they can be collected with --gc-sections linker option, but all strings still go in one section, and can't be collected individually. Is there a way to put strings in different sections? --data-sections option doesn't help. See this thread: https://lists.llvm.org/pipermail/llvm-dev/2020-September/145121.html Adding a `-fmerge-all-constants` option in case the linker really isn't able to get rid of unused strings should be trivial according to https://reviews.llvm.org/D45289. |
February 28, 2021 Re: All strings are in one section | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | Noticed another thing: typeinfos create type names 16 byte aligned (.rodata.str1.16) resulting in a lot of padding, but this alignment is not in IR. Is it a bug? |
February 28, 2021 Re: All strings are in one section | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | Well, it's one padding per object file, so maybe not that much. |
February 28, 2021 Re: All strings are in one section | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | Looks like it happens for any big string. immutable string b="12345678901234567"; This string will be 16 byte aligned. But it does happen for every string, not once per object file. |
March 15, 2021 Re: All strings are in one section | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Saturday, 27 February 2021 at 17:20:35 UTC, kinke wrote:
> On Saturday, 27 February 2021 at 14:46:55 UTC, Kagamin wrote:
>> On linux LLVM puts most things in different sections, so they can be collected with --gc-sections linker option, but all strings still go in one section, and can't be collected individually. Is there a way to put strings in different sections? --data-sections option doesn't help.
>
> See this thread: https://lists.llvm.org/pipermail/llvm-dev/2020-September/145121.html
>
> Adding a `-fmerge-all-constants` option in case the linker really isn't able to get rid of unused strings should be trivial according to https://reviews.llvm.org/D45289.
Could you add -fno-merge-all-constants option, please?
|
March 16, 2021 Re: All strings are in one section | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jack Applegame | On Monday, 15 March 2021 at 19:11:33 UTC, Jack Applegame wrote: > On Saturday, 27 February 2021 at 17:20:35 UTC, kinke wrote: >> On Saturday, 27 February 2021 at 14:46:55 UTC, Kagamin wrote: >>> On linux LLVM puts most things in different sections, so they can be collected with --gc-sections linker option, but all strings still go in one section, and can't be collected individually. Is there a way to put strings in different sections? --data-sections option doesn't help. >> >> See this thread: https://lists.llvm.org/pipermail/llvm-dev/2020-September/145121.html >> >> Adding a `-fmerge-all-constants` option in case the linker really isn't able to get rid of unused strings should be trivial according to https://reviews.llvm.org/D45289. > > Could you add -fno-merge-all-constants option, please? According to the IR tests in the linked LLVM PR, that's what LDC does anyway (emitting string constants as `private unnamed_addr`). Changing that to `internal` for -fmerge-all-constants semantics can be done in https://github.com/ldc-developers/ldc/blob/58ee56a2100eb301c55220933dd2a84d3a7d2843/gen/irstate.cpp#L205-L208. |
March 19, 2021 Re: All strings are in one section | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Saturday, 27 February 2021 at 17:20:35 UTC, kinke wrote:
> See this thread: https://lists.llvm.org/pipermail/llvm-dev/2020-September/145121.html
Indeed lld collects those strings.
|
Copyright © 1999-2021 by the D Language Foundation