VS Arduino
Visual Micro >> Installation & Troubleshooting >> link error in vs2019 of a project that builds ok in vs2017
https://www.visualmicro.com/forums/YaBB.pl?num=1622531166

Message started by Anders Eriksson on Jun 1st, 2021 at 7:06am

Title: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 1st, 2021 at 7:06am
Hi!
We have redesigned our board (based on arduino due) and added jtag connector and bought an atmel ice.

To be able to use this I had to upgrade to vs2019.

I have been able to build and debug with it in a simple "empty" arduino due project in vs2019.

BUT when I build our project that builds fine in vs2017 it reports link error in vs2019.

I have attached the output from
vs2017 and from vs2019 both with debug on hardware and without debugging

We have found a bug in the arduino library code for the Uart, so we have added the source code for the UartClass to our project and it builds and runs ok with vs2017


the diff is in the write function

original:

size_t UARTClass::write( const uint8_t uc_data )
{
  // Is the hardware currently busy?
  if (((_pUart->UART_SR & UART_SR_TXRDY) != UART_SR_TXRDY) |
      (_tx_buffer->_iTail != _tx_buffer->_iHead))
  {
    // If busy we buffer


our bug-fix version:

size_t UARTClass::write( const uint8_t uc_data )
{
  // Using static since it is faster, no stack operation
  static bool put_in_buffer;
 
  // Make sure that UART_SR_TXRDY and _tx_buffer is not changed by IrqHandler during evaluation
  __ASM volatile ("cpsid i");
  put_in_buffer = (((_pUart->UART_SR & UART_SR_TXRDY) != UART_SR_TXRDY) | (_tx_buffer->_iTail != _tx_buffer->_iHead));
  __ASM volatile ("cpsie i");
 
  // Is the hardware currently busy?
  if (put_in_buffer)
  {
    // If busy we buffer


Can you please help me found why I can't build this in vs2019

Best regards,
Anders Eriksson


https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vs2017_and_2019_build_output.zip ( 26 KB | 3 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 1st, 2021 at 9:06am
Hi again,

When I am comparing the output files, I see that i didn't build with Release option in vs2017, but now I have tried that also, see attached output file.

Thanks,
Anders
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vs2017_build_Release_output.txt ( 57 KB | 6 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Tim@Visual Micro on Jun 1st, 2021 at 2:19pm
Hi

On the 2017 version you have switched off "vMicro>Compiler>Deep Search for Libraries". This setting can be switched off if the .ino code has an #include for all the libraries that you need.

On the 2019 project you have switched off optimization which the core you are using is not designed to allow. You can see this in the output "-O0".

I suggest that switching the optimization to default is probably the solution because the library search looks okay, although possibly not needed in your project.


Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 1st, 2021 at 2:36pm
Hi,

I tried to use default optimization, but still same error, see attached output file.

Thanks,
Anders
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vs2019_no_debug_default_optimization_build_output.txt ( 109 KB | 4 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 1st, 2021 at 2:47pm
Hi again,

I see now when comparing the output that the vs2017 output has;

ide.default.revision_name=1.9.0

whereas vs2019 has
ide.default.revision_name=1.8.13

where can I change this setting to test this?

Thanks,
Anders

diff_between_vs2017_and_vs2019_output.png ( 732 KB | 4 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 1st, 2021 at 2:57pm
And now I found this strange path in the vs2019 output
-I"C:\SVN_proj\Arduino\MOTOR_~2\MOTORC~1"

whereas in vs2017 it is
-I"C:\SVN_proj\Arduino\motor_controller\MotorController"

see attached screen-dump

Can this enplane the link error? and how can it be fixed?

Thank, Anders
strange_include_path_in_vs2019.png ( 747 KB | 2 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 1st, 2021 at 3:04pm
Deep search library OFF didn't help either, see attached output file.
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vs2019_deep_search_lib_OFF_no_debug_default_optimization_build_output.txt ( 70 KB | 2 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Tim@Visual Micro on Jun 1st, 2021 at 3:30pm
Thanks for the info.

As a test, please set the optimization to "no project and libraries" then build and then set it back to default and build again. Then show the verbose output for the build.

The issue might be related to optimization not switching back to default after it has been on. This will show some useful info then I think we will be able to give you some settings for a short term workaround.

Thanks

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 1st, 2021 at 3:37pm
Link error in both, see attached output files
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=No_proj_plus_lib.txt ( 70 KB | 6 Downloads )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=default_opt.txt ( 70 KB | 7 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Tim@Visual Micro on Jun 1st, 2021 at 5:26pm
The only way I can replicate is if I change the advanced optimization settings (Project Properties).

Is it possible you have you added -O0 or the library and project "extra flags"? or disabled lib and project in same section?

See both sets of settings off and/or empty in the attached image.


advanced-optimization-settings_001.png ( 10 KB | 17 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 2nd, 2021 at 6:35am
But how does this setting differs between running visualmicro in vs2017 and vs2019, remind that it builds fine in vs2017?

And I can't remember me or any of my other colleagues have been changing this flag

I did email you the complete project yesterday to sales@visualmicro.com

Thanks,
Anders

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 2nd, 2021 at 6:37am
If you prefer we could use teamviewer so you can run on my machine?

Thanks,
Anders

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 2nd, 2021 at 6:49am
the 3 optimization flags are not existing in the vs2017 project settings, see attached screen-dumps of the project settings inside vs2017 and vs2019
vs2017_project_settings.png ( 199 KB | 6 Downloads )
vs2019_project_settings.png ( 64 KB | 2 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 2nd, 2021 at 7:01am
I tried to set the 3 new project properties that disables optimization for core, Libraries and project and it then builds ok!!!

BUT the prog size is 5% bigger in vs2019 than building the same project with vs2017, how come this big difference?

see attached screen-dumps
vs2019_builds_when_all_3_disable_opt_set_true_but_prog_size_is_31percent.png ( 137 KB | 3 Downloads )
vs2017_build_size_is_26percent.png ( 509 KB | 7 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 2nd, 2021 at 7:14am
I continued to test different combinations of these 3 new opt disable flags and found that only the disable optimization for project is necessary, but still prog size is 5% bigger, see attached screen-dump 
vs2019_builds_when_only_disable_opt_set_true_for_project_but_prog_size_is_31percent.png ( 243 KB | 3 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Tim@Visual Micro on Jun 2nd, 2021 at 12:25pm
Hi

Thanks for all the info. We need to look into where the disabling of the optimization is coming from.

In the meantime, this switch is the normal/default mode which is what you should be seeing.

[code]-Os[/code]

If you use that switch it will leave optimization on/normal.


Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 2nd, 2021 at 1:49pm
Hi yes -Os is shown in the output for both building in vs2017 and vs2019, but what about the prog size difference, about 30Kbyte more with vs2019?

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Simon@Visual Micro on Jun 4th, 2021 at 10:18am
Would it be possible to attach a clean set of logs from both VS2017 and VS2019 for review?

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 4th, 2021 at 10:35am
Certainly I really would like this to be solved.

Note the prog sizes
for vs2017:
Program MotorController size: 132 444 bytes
but for vs2019:
Program MotorController size: 162 588 bytes

https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vs2019_build_output_2.txt ( 67 KB | 2 Downloads )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vs2017_build_output_2.txt ( 57 KB | 4 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Tim@Visual Micro on Jun 4th, 2021 at 10:30pm
Hi, thanks very much for all the feedback and trials. We have found the issue. It relates to having previously disabled optimization, the switch off isn't working correctly.

There have been a number of other minor updates that are currently being tested and a new release will be made before Monday. We will update this thread when the release is made.




Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Simon@Visual Micro on Jun 7th, 2021 at 8:13am
The latest release is available in the Marketplace from within VS (21.06.06.0) which should resolve these issues around optimization.

The very latest fixes are also available from the top of the forum board below:
https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 7th, 2021 at 9:21am
I have updated to the 6 June release.

But I still don't get the same prog size as with vs2017, still about 30Kbyte more, what setting is still missing?

See attached outputs, one with default optimization and one with NO optimization
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vs_2019_with_6June_update_default_optimazation_result_in_162588Bytes.txt ( 67 KB | 4 Downloads )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=vs_2019_with_6June_update_NO_optimazation_result_in_170564Bytes.txt ( 71 KB | 3 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Simon@Visual Micro on Jun 7th, 2021 at 9:35am
Thanks for the detail, the -Og flag is still present so it is expecting this to be default optimization with a Hardware debugger selected.

Just for clarity can you confirm there are no project properties set which change the optimization?

Is the result the same if you re-select the Optimization Setting "Default" from the Debug toolbar/menu?

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 7th, 2021 at 11:06am
Yes it is consistent doesn't get better after more trials switching between Default and NO opt, see the attached screen dump showing where I change the "Default" and "No optimization"

From my point of view it is strange that this behavior change and I need to change some setting just because I change from vs2017 to vs2019 to get the same generated code?

I have also added a dump of the project settings.

I tested again to open vs2017 with exactly the same MotorController.sln and rebuild it with output: about 30KBytes less than with vs2019

Program MotorController size: 132 444 bytes (used 25% of a 524 288 byte maximum) (10,83 secs)

optimization_where_I_change_in_the_gui.png ( 1216 KB | 5 Downloads )
project_settings_001.png ( 102 KB | 2 Downloads )

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Simon@Visual Micro on Jun 7th, 2021 at 11:11am
Thanks for the detail, there is a project setting in the properties image "Disable Optimization Project" which is set to True currently.

If you set that back to False they should yield the same result.

This setting isn't noted by VS2017 as the vMicro version installed there is much older (which is why these properties did not show in the earlier screenshots).

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 7th, 2021 at 11:17am
Sorry now I saw that the project setting for opt in proj was disabled, I set it to false.

And now it builds with exactly same output size:
Program MotorController size: 132 444 bytes (used 25% of a 524 288 byte maximum) (9,75 secs)

Thanks!!!

Now I will start to use the Atmel Ice!

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Anders Eriksson on Jun 7th, 2021 at 11:18am
Just to be clear what these 3 new properties have as default values? Are they all False? if I open a vs2017 project with vs2019?

Title: Re: link error in vs2019 of a project that builds ok in vs2017
Post by Simon@Visual Micro on Jun 7th, 2021 at 11:21am
Yes they should all be False by default, and if you upgrade the VS2017 vMicro version as well they will be visible in both setups.

Glad the issue is resolved, and thanks again for the assistance and persistence in resolving this problem.

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.