-
Notifications
You must be signed in to change notification settings - Fork 684
Fix LLVM/clang conversion errors #2473
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
Fix LLVM/clang conversion errors #2473
Conversation
@miri64 Thanks for the PR. Some comments and questions:
|
Hi, I will address your comments. Is it okay, if I amend them to the existing commit? |
@miri64 As for the compiler version / platform / build settings question, just add here a comment. There's no need for putting that in a commit message. As for the style and signoff issues, the PR will need to have a single correct commit at the end, so it might be easier to simply amend the current one and force push it. |
Yes I was planning to do so, sorry to not having been clear on that. I just need to recheck that before I come back on that ;-). |
The |
b7dd5c8
to
66388e3
Compare
I amended the changes you asked for. As for the my previous comment: I rechecked now with a3112ab, but the compile issue with |
Interesting, my build of latest master with clang 3.8.0 on an Ubuntu 14.04.5 LTS (x86_64) runs without any diagnostics. Is your build setup considerably different from mine? CC=clang-3.8 tools/build.py --clean --lto=off --error-messages=on --external-context=on \
--jerry-debugger=on --line-info=on --logging=on --mem-stats=on --profile=es2015-subset \
--show-opcodes=on --show-regexp-opcodes=on --snapshot-exec=on --snapshot-save=on \
--valgrind=on --vm-exec-stop=on --jerry-libc=off --debug |
Mh, I can't tell exactly, but here is what I've got as
|
Here's more on my versions:
|
(with the command you provided I can't reproduce either by the way) |
Let's dig further and deeper if you don't mind. (It's itching that I don't understand what's happening.) Here is what I get when I run the cmake && make command copied from the RIOT CI logs (build directory adapted for local build and some progress messages deleted for the sake of brevity): $ clang-3.8 --version
clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
$ cmake -Bbuild -H. -DCMAKE_SYSTEM_NAME=RIOT -DCMAKE_SYSTEM_PROCESSOR="cortex-m4" -DCMAKE_C_COMPILER=clang-3.8 -DCMAKE_C_COMPILER_WORKS=TRUE -DENABLE_LTO=OFF -DFEATURE_VALGRIND=OFF -DENABLE_ALL_IN_ONE=OFF -DJERRY_LIBC=OFF -DJERRY_LIBM=OFF -DJERRY_CMDLINE=OFF -DEXTERNAL_COMPILE_FLAGS="-D__TARGET_RIOT" -DMEM_HEAP_SIZE_KB=16
-- The C compiler identification is Clang 3.8.0
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/clang-3.8
System is unknown to cmake, create:
Platform/RIOT to use this system, please send your config file to [email protected] so it can be added to cmake
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/RIOT to use this system, please send your config file to [email protected] so it can be added to cmake
-- Detecting C compiler ABI info - done
-- CMAKE_BUILD_TYPE MinSizeRel
-- CMAKE_C_COMPILER_ID Clang
-- CMAKE_SYSTEM_NAME RIOT
-- CMAKE_SYSTEM_PROCESSOR cortex-m4
[[[snip]]]
-- Configuring done
-- Generating done
-- Build files have been written to: /home/akiss/devel/jerry/jerryscript/build
$ make -Cbuild jerry-core jerry-ext jerry-port-default-minimal
make: Entering directory `/home/akiss/devel/jerry/jerryscript/build'
[[[snip]]]
Linking C static library ../lib/libjerry-core.a
[[[snip]]]
Linking C static library ../lib/libjerry-ext.a
[[[snip]]]
Linking C static library ../../lib/libjerry-port-default-minimal.a
[[[snip]]]
make: Leaving directory `/home/akiss/devel/jerry/jerryscript/build' The Ubuntu version difference (16.04 vs 14.04) simply shouldn't be the cause of difference as clang is of the same version. However, I've spotted that the CI logs contain the following line: May I ask you to run the cmake and make commands from above on your local machine? Meanwhile, I'll set up an Ubuntu 16.04 VM and see what result it gives for me. |
AFAIK we are using the stock Ubuntu
In that case I get the same output as you 🤔 |
Okay, I've tracked down the issue. The warnings are caused by the CC=clang-3.8 CFLAGS="-fshort-enums" \
tools/build.py --clean --lto=off --error-messages=on --external-context=on \
--jerry-debugger=on --line-info=on --logging=on --mem-stats=on --profile=es2015-subset \
--show-opcodes=on --show-regexp-opcodes=on --snapshot-exec=on --snapshot-save=on \
--valgrind=on --vm-exec-stop=on --jerry-libc=off --debug Notes:
Note to self: stock clang can cross compile to arm just fine with |
So how do we proceed? |
Now, I'll fetch your commit and try it out locally to see if everything is fine, as we don't have a CI for this build setting. (Most probably we wont have that in the future either as |
I still get precision loss errors:
Please, run the command in my above comment, it enables (close to) all macro-guarded code paths and fix the revealed issues (if there are any on top of these two). |
Since RIOT fixes jerryscript to one version, that shouldn't be so critical. Only if we update jerryscript, the maintainer might need to update upstream. |
66388e3
to
53fa1e2
Compare
Should be fixed now. |
|
||
uint32_t bit_for_index = (uint32_t) 1u << index; | ||
|
||
if (!(*bitset_p & bit_for_index) || ecma_op_object_has_own_property (object_p, name_p)) | ||
{ | ||
ecma_append_to_values_collection (for_non_enumerable_p, | ||
ecma_make_magic_string_value (curr_property_p->magic_string_id), | ||
ecma_make_magic_string_value ( | ||
(lit_magic_string_id_t) curr_property_p->magic_string_id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style is not really preferred, even though vera++ doesn't complain about it. It's not that nice either but breaking out the parameter into a local variable -- i.e., ecma_value_t name = ecma_make_magic_string_value ((lit_magic_string_id_t) curr_property_p->magic_string_id)
-- is a more accepted style hereabouts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
This fixes some conversion errors one gets when compiling with LLVM/clang. Most of them are caused when a bit-specific type (i.e. `uint16_t`) is implicitly cast to an `enum` of smaller value range. The fix is just an explicit casting of those types to the desired target type. JerryScript-DCO-1.0-Signed-off-by: Martine Lenders [email protected]
53fa1e2
to
76f03e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the review and analysis of the problem! |
Is there anything I still need to do to get this merged? |
@miri64 Right now, you are clear on your side. Project regulations mandate 2 approvals from maintainers, so one fellow reviewer still needs to take a look at the patch. Once you get that, and assuming that no changes are requested, the PR will be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you both for the review! |
This fixes some conversion errors one gets when compiling with LLVM/clang. Most of them are caused when a bit-specific type (i.e.
uint16_t
) is implicitly cast to anenum
of smaller value range.The fix is just an explicit casting of those types to the desired target type.