-
Notifications
You must be signed in to change notification settings - Fork 123
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
xtensa-esp-elf: how to influence endianness ? #271
Comments
During compilation... are you using and passing to the gcc compiler all supplied include files and in general all Cargs? |
For compilation we use cmake btw, not invoking the C compiler directly... |
@ivmarkov thx for the response, yes I am passing in all the flags I get from build_output - the code is here gopakumarce@d919224#diff-37bbeb3d6061a16a1b78c746bdf8b0c514d591ccdbf4ab731502d5d844b2c6c5R136 And yes I was trying to dig into the code as to where exactly or how exactly an xtensa gcc is told to use the right endianness - where in the cmake or configuration is that mentoned, ive been unsuccesful so far to dig that deep. Once I know how its done, then I can try doing the same when invoking gcc during bindgen |
Note that in the diff above I tried including xtensa/config/core.h into the bindgen generated C file, thats actually silly of me because including that into a C file should not have any influence on the endianness gcc produces - but at this point im just clueless and ready to try anything :) |
Ok, so as far as I can see, there really is no magic gcc flag, it uses So for my purpose, where I really want to compile a bindgen C file, I guess chips.gcc_toolchain() is not the right choice, I really need to use the exact |
No I don't think your assessment is correct. What actually happened, is that some time ago, there was only So now we have to use Or to summarize, there MUST be a way to use the generic |
I see, thx for the context. |
Surely there is a way how they pass the chip type (or rather, the target arch). I.think there are differences between esp32/esp32s2/esp32s3. |
@ivmarkov circling back to this thread - pls see espressif/crosstool-NG#50 - the esp-idf still uses the wrappers to compile/link, its just that the actual compiler is just built once, and the espXXX versions are just wrappers to the one built compiler. Now coming to 31d27d7 - I guess I understand what the intent was, so the chips.gcc_toolchain() API can basically be thought of as chips.gcc_toolchain_to_be_installed() - the API is just returning what has to be installed via esp-idf.py, and esp-idf.py is smart enough to know that if its told to install xtensa-esp-elf-gcc, it installs that AND all the wrappers. In my case, I was trying to interpret chips.gcc_toolchain() as chips.gcc_toolchain_used_to_compile() - and that should really be the wrappers. Would you like me to add two separate APIs clearly indicating the difference in intent ? |
… Vs linking See thread esp-rs#271 and espressif/crosstool-NG#50 The toolchain name that is supplied to idf-install.py Vs what is actually used when compiling/linking can be slightly different - the installation can be given one toolchain name and underneath installs multiple things, and at compile/link time one of those installed tools is selected based on the specific idf target
The original question about endianness was discussed. If you have further issues or want to provide separate context please create a separate new issue. Closing this for now. |
Maybe a question for @ivmarkov - so in the below commit, if the IDF version is "new", then the gcc used is just xtensa-esp-elf - that gcc has __XCHAL_HAVE_BE set to 1 .. So if I am compiling for esp32, what exactly is the magic going on behind the scenes to compile as little endian ? xtensa-esp32-elf has it set to 0 nicely. I see a lot of discussions online which says an "xtensa-overlays.h" or "xtensa-config.h" or "core.h" or "core-isa.h" can be used to influence gcc to produce BE/LE, but I cant find exactly how that works - any pointers will be highly appreciated
The reason to ask is because I am trying to compile a bunch of C files generated by/during bindgen such that it can be linked with the final image. But if I compile with the gcc got by the call to chips.gcc_toolchain() it produces BE code whereas the rest of the code is obviously LE. So how exactly do I go about solving this - in bindgen phase, how can I make sure that my C files are compiled as per the target CPUs endianness (LE for esp32 etc..) ?
The text was updated successfully, but these errors were encountered: