eclipse-embed-cdt / eclipse-plugins

The Eclipse Embedded CDT plug-ins for Arm & RISC-V C/C++ developers (formerly known as the GNU MCU Eclipse plug-ins). Includes the archive of previous plug-ins versions, as Releases.
http://eclipse-embed-cdt.github.io/
Eclipse Public License 2.0
554 stars 130 forks source link

Feature request: Add a checkbox to enable group linked library #592

Closed fanghuaqi closed 3 months ago

fanghuaqi commented 8 months ago

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

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:

Thanks Huaqi

ilg-ul commented 8 months ago

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?

fanghuaqi commented 8 months ago

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.

TommyMurphyTM1234 commented 8 months ago

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

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

fanghuaqi commented 8 months ago

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

TommyMurphyTM1234 commented 8 months ago

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.

ilg-ul commented 8 months ago

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:

laomaolaile commented 8 months ago

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

image

laomaolaile commented 8 months ago

Put it in other linker flags is also not working

image

image

laomaolaile commented 8 months ago

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

image image image

fanghuaqi commented 6 months ago

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

laomaolaile commented 4 months ago

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?

ilg-ul commented 4 months ago

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.

jld01 commented 4 months ago

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

laomaolaile commented 4 months ago

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

ilg-ul commented 4 months ago

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.

laomaolaile commented 3 months ago

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

ilg-ul commented 3 months ago

... 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.

laomaolaile commented 3 months ago

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

ilg-ul commented 3 months ago

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 commented 3 months ago

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?

TommyMurphyTM1234 commented 3 months ago

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?

ilg-ul commented 3 months ago

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 commented 3 months ago

@laomaolaile, please test the pre-release from:

laomaolaile commented 3 months ago

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

ilg-ul commented 3 months ago

Thank you for confirming.

I'll proceed with the 6.6.0 release.