Skip to content
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

Dependency Ordering Fix #18770

Closed

Conversation

rhapsodyv
Copy link
Member

@rhapsodyv rhapsodyv commented Jul 24, 2020

Description

When using TMC 2209 Uart, the lib TMCStepper depends on SoftwareSerialM (feature: HAS_TMC_SW_SERIAL). The problem is that no matter the way we send the dependencies to platformio lib_deps, it randomly send to the link the libs in the wrong order.

The linker needs: dependent first, dependency last. Because as it is compiling, it discards non used references (until the compiled file). So, if SoftwareSerialM appear before TMCStepper in the linker command line, all symbols in SoftwareSerialM will be discarded, because they aren't used yet. The correct order is: TMCStepper first, SoftwareSerialM last.

Both dependency graph puts the SoftwareSerialM before TMCStepper....

Dependency Graph
|-- <lvgl> 6.1.1
|-- <SoftwareSerialM> 1.0.0
|-- <TMCStepper> 0.7.1
|   |-- <SoftwareSerialM> 1.0.0
|-- <STM32ADC> 1.0
|-- <EEPROM>
|-- <USBComposite for STM32F1> 0.91
|-- <Wire> 1.0
|-- <FreeRTOS701>
|-- <Servo(STM32F1)> 1.1.2

Or

Dependency Graph
|-- <lvgl> 6.1.1
|-- <TMCStepper> 0.7.1
|   |-- <SoftwareSerialM> 1.0.0
|-- <SoftwareSerialM> 1.0.0
|-- <STM32ADC> 1.0
|-- <EEPROM>
|-- <USBComposite for STM32F1> 0.91
|-- <Wire> 1.0
|-- <FreeRTOS701>
|-- <Servo(STM32F1)> 1.1.2

This PR add a linker flag (-Wl,--start-group), to solve it.

Benefits

  • Fix dependency ordering issue
  • We won't be any more link ordering problem

Related Issues

#18699

@rhapsodyv rhapsodyv marked this pull request as draft July 24, 2020 20:28
@rhapsodyv rhapsodyv marked this pull request as ready for review July 24, 2020 20:40
@rhapsodyv rhapsodyv marked this pull request as draft July 24, 2020 21:16
@rhapsodyv rhapsodyv marked this pull request as ready for review July 24, 2020 21:23
@rhapsodyv
Copy link
Member Author

Closed until I get a better understanding of how SoftwareSerialM and SoftwareSerial are used.

@rhapsodyv rhapsodyv closed this Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant