Skip to content

Move code from a header to a .c file - #1005

Merged
lgirdwood merged 6 commits into
thesofproject:masterfrom
lyakh:idc
Feb 19, 2019
Merged

Move code from a header to a .c file#1005
lgirdwood merged 6 commits into
thesofproject:masterfrom
lyakh:idc

Conversation

@lyakh

@lyakh lyakh commented Feb 13, 2019

Copy link
Copy Markdown
Collaborator

compile- and run-tested on Up^2 with a couple of days old "master" branch. The current "master" doesn't build for me - "8d408eb cmake: add dist target" broke it.

@jajanusz

Copy link
Copy Markdown
Contributor

compile- and run-tested on Up^2 with a couple of days old "master" branch. The current "master" doesn't build for me - "8d408eb cmake: add dist target" broke it.

git clean -fdx, but please read this first: https://explainshell.com/explain?cmd=git+clean+-fdx

I guess you just have some artifacts from the old buildsystem maybe .tarball-version in repo?

@lyakh

lyakh commented Feb 13, 2019

Copy link
Copy Markdown
Collaborator Author

Is this the reason for this build failure:

16:17:11,589 INFO  - /localdisk/tools/xtensa/RG-2017.8-linux/XtensaTools/bin/xt-xcc    CMakeFiles/pipeline_new.dir/pipeline_new.c.o CMakeFiles/pipeline_new.dir/pipeline_mocks.c.o CMakeFiles/pipeline_new.dir/pipeline_mocks_rzalloc.c.o CMakeFiles/pipeline_new.dir/__/__/__/__/__/src/audio/pipeline.c.o  -o pipeline_new -T/quickbuild/workspace/24733/SOF_FW/build_ut/test/cmocka/memory_mock.x /localdisk/tools/cmocka/build_X6H3CNL_2017_8/install/lib/libcmocka-static.a 
16:17:11,601 INFO  - /localdisk/tools/xtensa/RG-2017.8-linux/XtensaTools/bin/xt-xcc    CMakeFiles/mixer.dir/mixer_test.c.o CMakeFiles/mixer.dir/mock.c.o CMakeFiles/mixer.dir/comp_mock.c.o CMakeFiles/mixer.dir/__/__/__/__/__/src/audio/buffer.c.o CMakeFiles/mixer.dir/__/__/__/__/__/src/audio/mixer.c.o  -o mixer -T/quickbuild/workspace/24733/SOF_FW/build_ut/test/cmocka/memory_mock.x /localdisk/tools/cmocka/build_X6H3CNL_2017_8/install/lib/libcmocka-static.a -lm 
16:17:11,621 WARN  - CMakeFiles/pipeline_new_allocation.dir/__/__/__/__/__/src/audio/pipeline.c.o: In function `idc_send_msg':
16:17:11,621 WARN  - pipeline.c:(.text+0x353): undefined reference to `arch_idc_send_msg'
16:17:11,628 INFO  - test/cmocka/src/audio/pipeline/CMakeFiles/pipeline_new_allocation.dir/build.make:129: recipe for target 'test/cmocka/src/audio/pipeline/pipeline_new_allocation' failed
16:17:11,628 INFO  - make[2]: Leaving directory '/quickbuild/workspace/24733/SOF_FW/build_ut'
16:17:11,628 WARN  - make[2]: *** [test/cmocka/src/audio/pipeline/pipeline_new_allocation] Error 2
16:17:11,628 INFO  - CMakeFiles/Makefile2:1154: recipe for target 'test/cmocka/src/audio/pipeline/CMakeFiles/pipeline_new_allocation.dir/all' failed
16:17:11,628 WARN  - make[1]: *** [test/cmocka/src/audio/pipeline/CMakeFiles/pipeline_new_allocation.dir/all] Error 2
16:17:11,628 WARN  - make[1]: *** Waiting for unfinished jobs....

? This seems to be not a "normal" build, but something cmocka-related. How do I reproduce it locally or why is it failing?

@jajanusz

jajanusz commented Feb 13, 2019

Copy link
Copy Markdown
Contributor

@lyakh
https://thesofproject.github.io/latest/developer_guides/unit_tests.html
You need xt-* (xt-xcc/xt-run) toolchain for that, do you have it or only gcc ?

? This seems to be not a "normal" build, but something cmocka-related. How do I reproduce it locally or why is it failing?

Yes, it's unit-test build, if you changed location of symbols they will not run until you update them

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh can you check CI

@lyakh

lyakh commented Feb 13, 2019

Copy link
Copy Markdown
Collaborator Author

@jajanusz ah, at least now I see what's failing, thanks! I don't have xt-xcc, but it seems relatively easy to "guess" what has to be done to fix this. Only it's a pity it takes so long to get a result... But anyway, I'll probably need a couple of iterations with the CI to get this right, sorry about the electricity bill :-)

@jajanusz jajanusz mentioned this pull request Feb 13, 2019
@jajanusz

jajanusz commented Feb 13, 2019

Copy link
Copy Markdown
Contributor

@jajanusz ah, at least now I see what's failing, thanks! I don't have xt-xcc, but it seems relatively easy to "guess" what has to be done to fix this. Only it's a pity it takes so long to get a result... But anyway, I'll probably need a couple of iterations with the CI to get this right, sorry about the electricity bill :-)

You can try to play with UTs as it may be helpful later, however it may be challenging to fix when you use UTs first time. Feel free to merge that: lyakh#1 +You can feel like a maintainer ;)

It should automatically update also this PR, I guess it can be the first PR in this repo with multiple commiters, so may be interesting as example for others - for example when one PR depends on another PR

@lyakh

lyakh commented Feb 13, 2019

Copy link
Copy Markdown
Collaborator Author

@jajanusz thanks a lot! Looking at the patch it would take me a bit more than a couple of rounds ;-) I thought I would have to create a mock up for the missing symbol.

@jajanusz

Copy link
Copy Markdown
Contributor

@jajanusz thanks a lot! Looking at the patch it would take me a bit more than a couple of rounds ;-) I thought I would have to create a mock up for the missing symbol.

You can create stubs when dependencies are 1 level, but I guess there are some spagetthi inside so it's easier to strip unused references

@jajanusz jajanusz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change commit message from 'Move code from a header to a .c file ' to topic: what's changes format

@lyakh

lyakh commented Feb 14, 2019

Copy link
Copy Markdown
Collaborator Author

@jajanusz sorry, what do you mean "what's changes format?" The patch isn't introducing any functional changes, it only moves code to a .c file to prevent it from being built multiple times. The only thing I can imagine that might be worth adding to the description is what code has been moved, i.e. maybe adding an "idc:" prefix, is that what you meant?
CI servers seem to have problems again :-/

@jajanusz

Copy link
Copy Markdown
Contributor

@jajanusz sorry, what do you mean "what's changes format?" The patch isn't introducing any functional changes, it only moves code to a .c file to prevent it from being built multiple times. The only thing I can imagine that might be worth adding to the description is what code has been moved, i.e. maybe adding an "idc:" prefix, is that what you meant?
CI servers seem to have problems again :-/

Yes. Something like idc: move implementation from header to .c file. I think all our commit use similar format (it's also in kernel)

@lyakh

lyakh commented Feb 14, 2019

Copy link
Copy Markdown
Collaborator Author

@jajanusz sure, can do that, but I've just pushed one more similar PR, and that one moves several headers... So there such a prefix would be difficult

@lyakh

lyakh commented Feb 14, 2019

Copy link
Copy Markdown
Collaborator Author

@jajanusz There we go: separate commits, with prefixes, one cmacka problem fixed by you, more expected... I'll close the other PR.

@jajanusz

Copy link
Copy Markdown
Contributor

@lyakh It looks like there are some fixes needed for GCC compilers. I'll fix unit tests after you fix compilation for travis/jenkis cis

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just keep this to larger functions.

Comment thread src/include/sof/wait.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep the small functions inline, this way we can avoid unnecessary calls and window exceptions on xtensa

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgirdwood should be better now

lyakh and others added 5 commits February 15, 2019 08:37
src/arch/xtensa/smp/include/arch/idc.h has way too much code for a
header, it is included by platform/idc.h on various platforms, and
that header in turn is included by bultiple .c files, which builds
the code multiple times into the firmware. Move it to a C file.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Many functions in src/include/sof/panic.h are too large to be inlined
and repeated every time the header is included. Move them out to
src/lib/panic.c

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Move large functions from src/arch/xtensa/include/arch/task.h to
src/arch/xtensa/smp/init.c to avoid building them multiple times.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Move large functions from src/include/sof/wait.h to src/lib/wait.c to
avoid building them multiple times.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
@lyakh

lyakh commented Feb 15, 2019

Copy link
Copy Markdown
Collaborator Author

@jajanusz presumably your UT fixes have to go in simultaneously with this PR?

@jajanusz

jajanusz commented Feb 15, 2019

Copy link
Copy Markdown
Contributor

@jajanusz presumably your UT fixes have to go in simultaneously with this PR?

Yes they have to be in the same PR. Otherwise QB CI check will fail what is merge-blocker. I'll try to add commit for fixing UTs later today

@lyakh

lyakh commented Feb 15, 2019

Copy link
Copy Markdown
Collaborator Author

@jajanusz that would be great, thanks! Otherwise we might have to rebase again, and then again, and... :-)

@jajanusz

Copy link
Copy Markdown
Contributor

@jajanusz that would be great, thanks! Otherwise we might have to rebase again, and then again, and... :-)

This one was easy: lyakh#2 ;p

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
@lgirdwood

Copy link
Copy Markdown
Member

@lyakh CI scan

@lyakh

lyakh commented Feb 19, 2019

Copy link
Copy Markdown
Collaborator Author

@lyakh CI scan

@lgirdwood Nice, all the issues I've looked at so far are (logically) not mine - I only copied them over from .h to .c. That being said, many of them are real and have to be fixed. Some are also false positives, e.g. an infinite loop in the panic() implementation ;-) What I'm wondering though: hasn't the complete SOF source base been verified by KW? It seems to be a bit strange to me to use it for new submissions without having applied it to the existing code.
Anyway, what would be the proposed way to fix this? The easiest way for me would be to add patches on top - either in a new patch series (would make it even easier to not have to rebase a couple more times, but would possibly hide some bugs), or as additional patches in this series. But the "correct" way would be to first fix bugs, and then move the code... But that would make it complex, because you only see those bugs when you try to move code around.
I think the best option would be adding patches to this PR on top of the current ones - that way we make sure that we don't miss any bugs. Would that be acceptable?

@lgirdwood

Copy link
Copy Markdown
Member

@lyakh yes incremental should be fine.

@lgirdwood
lgirdwood merged commit 5ccbab2 into thesofproject:master Feb 19, 2019
@lyakh
lyakh deleted the idc branch February 19, 2019 17:27
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.

3 participants