-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
cmake: set -DWITH_CPU and -DWITH_ARCH for kodi #1128
Conversation
my two cents on this.
EDIT: make sure -DWITH_ARCH= is always correctly passed to kodi's cmake. remove DWITH_CPU and be done with it. |
Yes, in theory we shouldn't, but in practice we do. If we don't pass WITH_ARCH then RPi fails with a duff CPU. If we pass WITH_CPU (and give Kodi our real TARGET_CPU) then Kodi chokes on that because our TARGET_CPU is bogus. At a minimum we could give Kodi just CPU (modified to work around Generic), but giving it both CPU and ARCH simply avoids any potential for confusion.
We did that, giving Kodi only WITH_ARCH, and Kodi then doesn't know the CPU (for RPi/RPi2) so it doesn't apply any optimisations. I spent a couple of hours debugging this with @wsnipex this morning, testing the various combinations - nothing, WITH_ARCH, WITH_CPU - and giving Kodi both WITH_CPU and WITH_ARCH works in all cases and puts this issue to bed once and for all. Hopefully. Probably. Well, until next time anyway. |
Needless to say this needs to be tested for all platforms other than RPi/RPi2/Generic, although I'm not expecting any issues as we were already setting WITH_ARCH for everything but Generic, so the only difference now is that WITH_CPU is also being passed which should prevent misidentification of the CPU when selecting optimisations. |
as said, kodi should stop treating rbpi like it is a complete different platform, this is something to be fixed upstream, not by workarounds in distro buildsystems. |
@stefansaraev any thoughts on why the Generic TARGET_CPU is seemingly incompatible with accepted usage, ie. we have |
it is used with gcc's -march (config/arch.x86_64). I am pretty sure x86_64 is not accepted as a cpu type for -march so you better dont touch that. The generic x86-64 -march is -march=x86-64. do what "other distributions" ? |
I think I was the one who added x86_64 to openelec few years back. at that time TARGET_CPU=x86-64 was only supposed to be used as a generic -march= optimization flag. no idea if now any other packages in LE (mis)-use it (the one I know is ffmpeg, and last time I checked it was doing it right) however, as said, after quick look at kodi cmake files, WITH_CPU usage seems inconsistent to me (what does arm1176jzf-s vs arm64-v8a vs arm and so on means?). on rpi the only thing it is doing is disabling neon, but you already have -mfpu=vfp in your CFLAGS. I know, rpi is so special. |
Thanks for that - interesting, and yet confusing. :)
So -march=
Well, so I've been told: "
To be honest it's not often (if ever?) been an issue to my knowledge, and is only now an issue because of trying to work around the Kodi CPU/ARCH detection which kinda sorta works. Except when it doesn't. If the hack in this PR works I'd be more than happy to find more interesting things to worry about, as I don't think there's much chance of a fix upstream (assuming one is even necessary, which is maybe 50/50). |
I don't really agree with this. I don't think we should change our build system to work around a kodi quirk. |
Then we continue to tell Kodi (and maybe other packages) that our CPU is All this change really does is to pass to cmake the correct CPU (for non-Generic) and correct ARCH (for Generic). If you'd rather not pass the CPU for Generic (as there's obviously disagreement over what it should be, hyphen or underscore), then I can remove that. But passing the correct CPU and ARCH for ARM builds seems better than compiling for an Upstream (Kodi) won't change anything, so I'm told. So either we do, by patching Kodi, or modifying our build system to pass all the right details to cmake (ie. this PR), or we continue building for random and non-existent CPUs. |
-DWITH_CPU and -DWITH_ARCH are not cmake global options. they are package specific, so they dont belong in global *_CMAKE_OPTS. you can do the change in kodi/package.mk. thats my last 2 cents :) |
OK if that's the case... I'll close this. Clearly I've been given bum advice. |
By the way thanks all that contributed to this conversation. |
Reopening with one last spin of the dice. If this isn't acceptable, then close. Edit: Title updated. |
I am either blind or stupid. I cant find a cmake file in kodi git where specific optimizations are done based on -DWITH_CPU. can't find rpi specifics either (besides disabling neon, and you already have an option to pass -DENABLE_NEON=OFF/ON). can you point me to a cmake file where such optimizations (C*FLAGS and so on) are done? |
Not yet merged: xbmc/xbmc#11352 |
a proposed PR does not mean it is done right (EDIT: it adds more to the mess you were told that wont be changed). now it makes -DWITH_CPU non optional?
EDIT: however, this PR now looks fine to me, if you want it that much for little to no gain :) |
This change came about after discussion with @wsnipex and xbmc/xbmc#11343
It turns out that with the current LE build system, when building Kodi, we set
-DWITH_CPU=$TARGET_ARCH
for Generic, and-DWITH_ARCH=$TARGET_ARCH
for everything else.This has the effect that for RPi/RPi2 the CPU is not correctly determined:
RPi:
RPi2:
Generic:
If we completely remove the
-DWITH_CPU
and-DWITH_ARCH
from kodi/package.mk then Generic builds normally, but the RPi/RPi2 builds fail as now ARCH is not determined and CPU is instead detected asarm
:arm
is coming from CMAKE_SYSTEM_PROCESSOR in the toolchain file. Despite sounding like it should be set to the processor type, this property is apparently set correctly as the target platform architecture.If we then always set
-DWITH_CPU=$TARGET_CPU
then RPi/RPi2 builds will succeed (xbmc/xbmc#11343 will ensure the ARCH is set correctly, but not the CPU), but now Generic fails with invalid CPU - this is because TARGET_CPU on Generic isx86-64
which is bogus. For some reason our TARGET_CPU on Generic has a hyphen, not an underscore.With the change in this PR cmake will always know both CPU AND ARCH every time we build with cmake, and - unlike when CPU is unknown - all suitable optimisations will be applied by cmake now that it knows both CPU and ARCH.
RPi:
RPi2:
Generic:
On RPi and RPi2, the files and filenames in before/after images are indentical.
On Generic, there are 4 files that change name - #0103i is the new build that includes this PR:.
In the new build, the four files no longer include the
-linux
platform suffix. So far I have not seen any problem with this change.Question
Why do we have TARGET_CPU=
x86-64
(with hyphen)? Should we change this to underscore instead and avoid this headache in future?