eclipse-plugins icon indicating copy to clipboard operation
eclipse-plugins copied to clipboard

Feature request: Add an checkbox to enable group linked library

Open fanghuaqi opened this issue 1 year ago • 15 comments

Hi @ilg-ul ,

I would like to request a feature like below:

image

Adding a checkbox in Settings -> Linker -> Libraries, this checkbox is used to control group libraries or not

  • [ ] Group libraries(-Wl,start-group $LIBS -Wl, end-group)

When this checkbox is clicked, the generated Makefile will be like this:

image

Otherwise, it will be like this, which is the default behavior

image

This feature is used to fix issue like this If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference.

image

See reference links below:

  • https://stackoverflow.com/questions/5651869/what-are-the-start-group-and-end-group-command-line-options
  • https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_2.html

Thanks Huaqi

fanghuaqi avatar Oct 17 '23 02:10 fanghuaqi

Thank you for the suggestion, I'll think about it.

@jonahgraham, do you know of something similar in CDT? If not, are there any plans to implement it?

ilg-ul avatar Oct 17 '23 08:10 ilg-ul

Thank you for the suggestion, I'll think about it.

@jonahgraham, do you know of something similar in CDT? If not, are there any plans to implement it?

Thank you.

fanghuaqi avatar Oct 17 '23 08:10 fanghuaqi

In case it's of any relevance, this 10 year old CDT bug relates to the same issue:

  • https://bugs.eclipse.org/bugs/show_bug.cgi?id=398355

I'm not sure about "impossible" though, given that there seem to be workarounds - for example:

  • https://stackoverflow.com/questions/58817617/how-to-link-intel-mkl-using-eclipse-start-group-end-group

TommyMurphyTM1234 avatar Oct 17 '23 08:10 TommyMurphyTM1234

Hi @TommyMurphyTM1234 , it seems to be a CDT issue, workaround is not in an clean way, but I will take a try.

fanghuaqi avatar Oct 17 '23 08:10 fanghuaqi

Hi @TommyMurphyTM1234 , it seems to be a CDT issue, workaround is not in an clean way, but I will take a try.

I think it's more or less what @ilg-ul previously suggested for Embedded CDT. I just posted the links in case they were relevant to the comments about the base CDT.

TommyMurphyTM1234 avatar Oct 17 '23 08:10 TommyMurphyTM1234

I think it's more or less what @ilg-ul previously suggested for Embedded CDT.

That's correct. With the current implementation there are two solutions:

  • add the group as Miscellaneous -> Other linker flags
  • add the --start-group/--end-group in the Linker -> Expert settings -> Command line pattern

ilg-ul avatar Oct 17 '23 09:10 ilg-ul

Adding to Linker -> Misc -> Other Objects is not working.

image

laomaolaile avatar Oct 17 '23 09:10 laomaolaile

Put it in other linker flags is also not working

image

image

laomaolaile avatar Oct 17 '23 09:10 laomaolaile

Workaround like this, seems to work, but it is not a good way for normal user.

image image image

laomaolaile avatar Oct 17 '23 09:10 laomaolaile

Hi @ilg-ul @jonahgraham @jld01 , I see https://github.com/eclipse-cdt/cdt/issues/608 this issue is fixed, maybe embedded cdt plugin can support this group library feature now using this release https://github.com/eclipse-cdt/cdt/releases/tag/CDT_11_4_0, is there any work to do in this embedded cdt plugin?

image

fanghuaqi avatar Jan 03 '24 10:01 fanghuaqi

Hi @ilg-ul @jonahgraham @jld01

I created a MinGW GCC project using eclipse-embedcpp-2023-12-R-win32-x86_64, which already supports the Group libraries feature.

image

However, the created risc-v project currently does not support the Group libraries feature.

image

If want the risc-v project to also support Group libraries, do need to complete some development work?

If I want to achieve it and contribute, what should I do?

laomaolaile avatar Feb 23 '24 04:02 laomaolaile

The ARM & RISC-V managed build plug-ins and the MinGW managed build plug-in are different plug-ins and do not share code, so that button and the associated functionality must be reimplemented.

I currently don't know how complex this can be, the MinGW plug-in must be studied and a similar solution used, if possible.

ilg-ul avatar Feb 23 '24 08:02 ilg-ul

The CDT implementation was applied to the base GNU toolchain definitions of the Managed Build System (MBS). The MinGW GCC toolchain inherits this behaviour from the base definitions. The following diff provides a summary of the work involved: https://github.com/eclipse-cdt/cdt/compare/08abfa2..f5754e2

jld01 avatar Feb 23 '24 15:02 jld01

Hi @ilg-ul @jld01

Maybe I expressed wrongly. The key point is not MinGW GCC. I just want to know if can add Group libraries to the risc-v's GNU IRSC-V Corss C++ Links page, and if it supports this usage after adding it.

image

image

laomaolaile avatar Feb 26 '24 08:02 laomaolaile

if can add Group libraries to the risc-v's

If we decide to implement it, It must be added to the common plug-in and it'll be inherited to both RISC-V and Arm.

if it supports this usage after adding it.

I have no experience with this use case.

But you don't have to patch the plug-ins to use it, you can manually define all those options in the Miscellaneous field.

ilg-ul avatar Feb 26 '24 08:02 ilg-ul

Hello, this issue has been raised for some time now, and support for it is already available in CDT. May I ask if anyone is currently working on addressing this requirement?

@ilg-ul @jld01

laomaolaile avatar Mar 14 '24 08:03 laomaolaile

... anyone is currently working on addressing this requirement?

Unfortunately my resources are very limited and I cannot commit on a date, so any contributions are appreciated.

ilg-ul avatar Mar 14 '24 16:03 ilg-ul

I have completed the development of the function. How can I share the code?

The demonstration effects in the ARM project are as follows:

When Group libraries unchecked:

image

image

When Group libraries checked:

image

image

The demonstration effects in the RISC-V project are as follows:

When Group libraries unchecked:

image

image

When Group libraries checked:

image

image

laomaolaile avatar Mar 15 '24 09:03 laomaolaile

I took a look at this issue and I'm a bit confused, the solution I saw in CDT did not work in my projects, adding a LibrariesCommandGenerator to surround the list of libraries via -Wl,--start-group %s -Wl,--end-group failed because the resulting string is expected to have no spaces, otherwise they're escaped with a backslash and the compiler is not happy with them.

My solution was to generate everything as a single -Wl, string, like:

-Wl,--start-group,-lone,-ltwo,-lthree,--end-group

Any comments on this solution? @jld01, @laomaolaile ?

ilg-ul avatar Mar 19 '24 19:03 ilg-ul

As window layout, I would add the new option just below the list of libraries, since it applies to them, like this:

Screenshot 2024-03-19 at 21 12 41

What do you think?

ilg-ul avatar Mar 19 '24 19:03 ilg-ul

As window layout, I would add the new option just below the list of libraries, ...:

That makes sense to me but unfortunately seems to deviate from where CDT places it, and perhaps all plugins should be consistent?

  • https://github.com/eclipse-embed-cdt/eclipse-plugins/issues/592#issuecomment-1875135870

TommyMurphyTM1234 avatar Mar 19 '24 19:03 TommyMurphyTM1234

unfortunately seems to deviate from where CDT places it

yeah, but the behaviour is also slightly different. and it is not widely used by CDT, probably it is Windows specific, since I don't see it on my Mac.

ilg-ul avatar Mar 19 '24 20:03 ilg-ul

@laomaolaile, please test the pre-release from:

  • https://download.eclipse.org/embed-cdt/builds/develop/p2/

ilg-ul avatar Mar 19 '24 21:03 ilg-ul

I have tested it and it's exactly the function I want. Thank you very much. @ilg-ul

laomaolaile avatar Mar 20 '24 11:03 laomaolaile

Thank you for confirming.

I'll proceed with the 6.6.0 release.

ilg-ul avatar Mar 20 '24 11:03 ilg-ul