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

avr-gcc: Undefined references to __iob from unity.c #567

Open
davidrea opened this issue Jul 7, 2021 · 4 comments
Open

avr-gcc: Undefined references to __iob from unity.c #567

davidrea opened this issue Jul 7, 2021 · 4 comments

Comments

@davidrea
Copy link

davidrea commented Jul 7, 2021

It seems that the avr-gcc header files inject references to the __iob input/output buffer symbol, so attempting to mock any avr-gcc module with #include <avr/io.h> will cause the following linker errors:

<<snip>>
Compiling mock_io_manager.c...
Linking test_stateMachine_interface.out...
/usr/bin/ld: build/test/out/c/unity.o: in function `UnityPrintChar':
/var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src/unity.c:84: undefined reference to `__iob'
/usr/bin/ld: /var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src/unity.c:89: undefined reference to `__iob'
/usr/bin/ld: /var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src/unity.c:90: undefined reference to `__iob'
/usr/bin/ld: /var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src/unity.c:95: undefined reference to `__iob'
/usr/bin/ld: /var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src/unity.c:96: undefined reference to `__iob'
/usr/bin/ld: build/test/out/c/unity.o:/var/lib/gems/2.7.0/gems/ceedling-0.30.0/vendor/unity/src/unity.c:101: more undefined references to `__iob' follow
collect2: error: ld returned 1 exit status

@stephendpmurphy also ran into this problem in tiny.oled-firmware #13 but that issue remains unsolved...

My first thought on a workaround was to include a dummy __iob object (or maybe a re-redirect back to standard host OS streams) in a source file within test/support/ for the linker to resolve, but I'm not sure where to start.

@mvandervoord
Copy link
Member

Any non-standard compiler-specific defines like this can usually be avoided by adding the following to your cmock configuration:

:cmock:
   :strippables:
      - __iob

These values will then be stripped from the file before it is parsed for function prototypes.

@davidrea
Copy link
Author

davidrea commented Jul 7, 2021

Awesome - will give it a try!!

@davidrea
Copy link
Author

davidrea commented Jul 8, 2021

Hmm...no dice...still getting the undefined reference errors at the link stage. Tried running ceedling clobber beforehand too, just to make sure we started fresh.

Also tried while using the fake_function_framework plugin, same results.

@mvandervoord
Copy link
Member

Hm. I hadn't noticed that the problem is in the linker step. strippables is only going to help during mocking.

It's strange that it's citing unity as the thing that contains __iob. I notice that you're on an older ceedling... but honestly I don't recall that ever being part of unity? If you search unity.cpp or its header files for that, does it show up?

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

No branches or pull requests

2 participants