Skip to content

optional Library option dot_a_linkage not taken into account #1126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JAndrassy opened this issue Jan 11, 2020 · 10 comments
Closed

optional Library option dot_a_linkage not taken into account #1126

JAndrassy opened this issue Jan 11, 2020 · 10 comments
Assignees
Labels
domain: build The build does not work as the Arduino IDE. fixed in nightly OS: all status: Arduino IDE incompatibility Somethig that is not exactly the same as the arduino ide

Comments

@JAndrassy
Copy link

JAndrassy commented Jan 11, 2020

The build invokes linker with the .o from from libraries. This creates a different build result then invoking the linker with .a or .ar files for libraries, because files listed on linker command line are 'starting points' of compilation while objects from archives are added only if they are required by .o files from linker command line.

To reproduce, build for AVR the ImprovedKeyboard example of HID-Project library with Arduino IDE and with Sloeber. Then compare the size. Generate a .map file and you will see that the elf file created by Sloeber includes classes for all HID devices of the library while the elf file build by ArduinoIDE only contains the ImprovedKeyboard. (Additional problem is that in the sketch built by Sloeber all singeltons for HID devices are present and register themselves as USB endpoints, but there is space only for 3 endpoints. NicoHood/HID#199)

The build process should create archives (.a or .ar) for libraries and then add this archives on linker command line instead of listing the .o files.

To fix this, the makefile generation must be enhanced. I have Sloeber running from source code for debugging. I see that the makefile system is adaptation of the CDT makefile system, but before going deeper I thought I open an issue to discuss this.

@jantje
Copy link
Member

jantje commented Jan 12, 2020

I'm impressed with your research :-)
This is a tricky one though. Yes the makefile generator is a adaptation from the CDT one (which is both experimental and about to get deprecated :-s ).

But the makefile generator processes according to the extentionpoint org.eclipse.cdt.managedbuilder.core.buildDefinitions

In that extentionpoint you will see that there is a definition for archived links AR_OBJ inputs that states the output is .o (for C C++ and assembly)
https://github.com/Sloeber/arduino-eclipse-plugin/blob/master/io.sloeber.core/plugin.xml#L214

The same AR_OBJ is then available for input and again tagged as .o files.
https://github.com/Sloeber/arduino-eclipse-plugin/blob/master/io.sloeber.core/plugin.xml#L339

It could be that simply changing the o to a or ar in the input type definition solves your issue.

But it will do so for all cases so that would need extensive testing. For which there is a junit test :-)

@jantje
Copy link
Member

jantje commented Jan 12, 2020

Och I think I misunderstood.
You are talking about libraries, not the arduino platform stuff.
Here you will need to mod the name providers
The name providers of the output type act like filters (this is one of the mods I did to the CDT gnu make file generator)
By having 2 output types for the same input type sloeber triages the files to the archiver or the linker.
So the LinkNameProvider and the ArchiveNameProvider must be mutually exclusive.
At this point in time ArchiveNameProvider returns null for library related files and LinkNameProvider returns valid names.
Switching that should do the trick.

https://github.com/Sloeber/arduino-eclipse-plugin/blob/master/io.sloeber.core/src/io/sloeber/core/toolchain/LinkNameProvider.java#L29
https://github.com/Sloeber/arduino-eclipse-plugin/blob/master/io.sloeber.core/src/io/sloeber/core/toolchain/ArchiveNameProvider.java#L30

@JAndrassy
Copy link
Author

JAndrassy commented Jan 12, 2020

thank you Jantje. we are on the right path. I added

 } else if (primaryInputNames[curPath].toString().startsWith("libraries") && (bUseArchiver)) {
  outputNames[curPath] = Helpers.GetOutputName(primaryInputNames[curPath]).addFileExtension("o"); //$NON-NLS-1$

in ArchieveNameProvider and the same if condition with return null in LinkNameProvider.

the build is a success, but all .o files from libraries are in arduino.ar. it would be nicer if every library had own .ar

@JAndrassy
Copy link
Author

even the Arduino builder doesn't build .ar for libraries at default. it is an option in library.properties which the library author can set

from https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification

dot_a_linkage - (available from Arduino IDE 1.6.0 / arduino-builder 1.0.0-beta13) (optional) when set to true, the library will be compiled using a .a (archive) file. First, all source files are compiled into .o files as normal. Then instead of including all .o files in the linker command directly, all .o files are saved into a .a file, which is then included in the linker command. 1.5 format library folder structure is required.

@jantje
Copy link
Member

jantje commented Jan 12, 2020

it would be nicer if every library had own .ar
With the current approach I wouldn't know how to get there

@JAndrassy
Copy link
Author

after I found out about dot_a_linkage setting in library.properties I would see as a priority to link with this libraries over .ar, no matter if it is all done over the arduino.ar

@jantje
Copy link
Member

jantje commented Jan 13, 2020

That would be very similar to what is there already.
Currently the flag bUseArchiver means "Is the arduino code compiled as a archive or not" (Some platforms had to be build without the archiving step)
The biggest problem to face is: get the value of the flag. Not a huge problem so this should be relatively easy.

@jantje jantje added domain: build The build does not work as the Arduino IDE. OS: all status: Arduino IDE incompatibility Somethig that is not exactly the same as the arduino ide labels Jan 14, 2020
@jantje jantje changed the title We need to link with libraries as archive files, not as .o files optional Library option dot_a_linkage not taken into account Jan 14, 2020
jantje pushed a commit that referenced this issue Oct 9, 2022
Stuff is not finished but to many changes
I seperated the code for the main makefile the mksubdir and makefile
mksubdir is slowly geting rewritten
jantje pushed a commit that referenced this issue Oct 14, 2022
Changing a header file does not trigger the needed builds
jantje pushed a commit that referenced this issue Oct 14, 2022
jantje pushed a commit that referenced this issue Oct 14, 2022
I'm not yet happy with the use of caller
jantje pushed a commit that referenced this issue Oct 15, 2022
I want to check in as I did lots of changes
Building doesn't work anymore as the top level
rules are missing
jantje pushed a commit that referenced this issue Oct 20, 2022
The makefile is starting to get populated
jantje pushed a commit that referenced this issue Oct 23, 2022
jantje pushed a commit that referenced this issue Oct 24, 2022
jantje pushed a commit that referenced this issue Oct 24, 2022
jantje pushed a commit that referenced this issue Nov 6, 2022
jantje pushed a commit that referenced this issue Nov 22, 2022
jantje pushed a commit that referenced this issue Dec 3, 2022
Stuff is not finished but to many changes
I seperated the code for the main makefile the mksubdir and makefile
mksubdir is slowly geting rewritten
jantje pushed a commit that referenced this issue Dec 3, 2022
Changing a header file does not trigger the needed builds
jantje pushed a commit that referenced this issue Dec 3, 2022
jantje pushed a commit that referenced this issue Dec 4, 2023
Allow turning on/off parts
jantje pushed a commit that referenced this issue Dec 4, 2023
Though not everything is used (and probably I will not use it) and most
of it doesn't work; I'm checking it in to avoid lost work.
jantje pushed a commit that referenced this issue Dec 5, 2023
Expanding the dependency command in MakeRule int the make way makes the
dependency files 100% compatible between the internal and make builder.
jantje pushed a commit that referenced this issue Dec 5, 2023
jantje pushed a commit that referenced this issue Dec 5, 2023
needs code activation and testing to be completed but I need Sloeber for
that.
jantje pushed a commit that referenced this issue Dec 6, 2023
jantje pushed a commit that referenced this issue Dec 7, 2023
Also persistency works
The libs are not yet added to the command line
jantje pushed a commit that referenced this issue Dec 7, 2023
jantje pushed a commit that referenced this issue Dec 14, 2023
jantje pushed a commit that referenced this issue Dec 14, 2023
jantje pushed a commit that referenced this issue Dec 14, 2023
Supporting the managed build way will not work with this class.
jantje pushed a commit that referenced this issue Dec 16, 2023
I needed a sorting for the regression tests
jantje pushed a commit that referenced this issue Dec 16, 2023
@jantje jantje self-assigned this Feb 20, 2024
jantje pushed a commit that referenced this issue Mar 8, 2024
jantje pushed a commit that referenced this issue Jul 30, 2024
jantje pushed a commit that referenced this issue Aug 6, 2024
Because now the build/discovery commands are run by cmd on windows the
workarounds had to be completely different.
@jantje jantje closed this as completed in 368f055 Aug 7, 2024
jantje added a commit that referenced this issue Aug 7, 2024
…ary_archives

#1126 support for creating library archives
@jantje
Copy link
Member

jantje commented Aug 13, 2024

This id finally fixed in the nightly.
A unit test has been added to compiled the HID-project examples.
This will be part of the next release 5.0

@JAndrassy
Copy link
Author

@jantje
V4/nightly shows only 4.4.1.20220907
V5/nightly doesn't work
I downloaded and installed product 4.4.3 today to try this

@jantje
Copy link
Member

jantje commented Aug 14, 2024

I should call it actions instead of nightly.
My build server is down since 7 september 2022 and I stopped trying to revive it.
You can click on actions at the top of this page and get the latest successful master build. That is now the definition of "nightly"
Please note the nightly is V5.0 and is still in early testing. Please join the test effort #1660 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: build The build does not work as the Arduino IDE. fixed in nightly OS: all status: Arduino IDE incompatibility Somethig that is not exactly the same as the arduino ide
Projects
None yet
Development

No branches or pull requests

2 participants