-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 gcc armel/arm64 build #53220
Fix gcc armel/arm64 build #53220
Conversation
7de81d5
to
7ab98a8
Compare
src/coreclr/jit/codegenarm.cpp
Outdated
@@ -460,7 +460,7 @@ void CodeGen::genLclHeap(GenTree* tree) | |||
} | |||
|
|||
// regCnt will be the total number of bytes to locAlloc | |||
genSetRegToIcon(regCnt, amount, ((int)amount == amount) ? TYP_INT : TYP_LONG); | |||
genSetRegToIcon(regCnt, amount, ((int)amount >= 0) ? TYP_INT : TYP_LONG); |
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 does not look right, a narrowing cast is implementation-defined in C++.
also, it looks like we don't support TYP_LONG in
runtime/src/coreclr/jit/codegenarm.cpp
Line 183 in eee0ed2
// TODO-CrossBitness: we wouldn't need the cast below if we had CodeGen::instGen_Set_Reg_To_Reloc_Imm. |
that we are calling here, maybe use
ClrSafeInt
and cast to int always? cc @echesakovMSFT
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.
Yes, my bad, thanks. But it seems that original code is incorrect too
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.
I don't think this is relevant to CodeGen::instGen_Set_Reg_To_Reloc_Imm
issue in cross-bitness scenarious.
The change is for localloc
(i.e. .NET way of alloca
).
According to ECMA-335
The localloc
instruction allocates size (type native unsigned int
or U4
) bytes from the local
dynamic memory pool ...
I agree with Sergey that we should always use TYP_INT
here.
genSetRegToIcon(regCnt, amount, ((int)amount >= 0) ? TYP_INT : TYP_LONG); | |
genSetRegToIcon(regCnt, amount, TYP_INT); |
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.
Fixed, thanks
@@ -526,7 +526,7 @@ tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) | |||
break; | |||
|
|||
case UNW_ARM_FRAME_SYSCALL: | |||
printf("XXX1\n"); | |||
//printf("XXX1\n"); |
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.
not familiar with this code, what was the problem?
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.
[ 71s] In file included from /home/abuild/rpmbuild/BUILD/coreclr-6.0.0/src/coreclr/pal/src/libunwind/src/arm/Ltrace.c:4:
[ 71s] /home/abuild/rpmbuild/BUILD/coreclr-6.0.0/src/coreclr/pal/src/libunwind/src/arm/Gtrace.c: In function '_ULarm_tdep_trace':
[ 71s] /home/abuild/rpmbuild/BUILD/coreclr-6.0.0/src/coreclr/pal/src/libunwind/src/arm/Gtrace.c:529:7: error: incompatible implicit declaration of built-in function 'printf' [-Werror]
[ 71s] 529 | printf("XXX1\n");
[ 71s] | ^~~~~~
[ 71s] /home/abuild/rpmbuild/BUILD/coreclr-6.0.0/src/coreclr/pal/src/libunwind/src/arm/Gtrace.c:31:1: note: include '<stdio.h>' or provide a declaration of 'printf'
[ 71s] 30 | #include <limits.h>
[ 71s] +++ |+#include <stdio.h>
[ 71s] 31 |
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.
Would adding #include <stdio.h>
at the beginning of the file fix the issue or it would introduce some other errors?
cc @janvorli
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 should not be modified here. We use a verbatim copy of the libunwind library (https://github.com/libunwind/libunwind) and all necessary changes should be made upstream.
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.
I've removed this change from here
cc @dotnet/jit-contrib |
@@ -319,7 +319,7 @@ class LightWeightMap : public LightWeightMapBuffer | |||
|
|||
// If we have RTTI, we can make this assert report the correct type. No RTTI, though, when | |||
// built with .NET Core, especially when built against the PAL. | |||
AssertCodeMsg((ptr - bytes) == size, EXCEPTIONCODE_LWM, "%s - Ended with unexpected sizes %p != %x", | |||
AssertCodeMsg((unsigned int)(ptr - bytes) == size, EXCEPTIONCODE_LWM, "%s - Ended with unexpected sizes %p != %x", |
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.
I would rewrite it as follows to avoid casting
AssertCodeMsg((unsigned int)(ptr - bytes) == size, EXCEPTIONCODE_LWM, "%s - Ended with unexpected sizes %p != %x", | |
AssertCodeMsg(ptr == (bytes + size), EXCEPTIONCODE_LWM, "%s - Ended with unexpected sizes %p != %x", |
@@ -658,7 +658,7 @@ class DenseLightWeightMap : public LightWeightMapBuffer | |||
ptr += bufferLength * sizeof(unsigned char); | |||
} | |||
|
|||
AssertCodeMsg((ptr - bytes) == size, EXCEPTIONCODE_LWM, "Ended with unexpected sizes %Ix != %x", ptr - bytes, | |||
AssertCodeMsg((unsigned int)(ptr - bytes) == size, EXCEPTIONCODE_LWM, "Ended with unexpected sizes %Ix != %x", ptr - bytes, |
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.
Same here
AssertCodeMsg((unsigned int)(ptr - bytes) == size, EXCEPTIONCODE_LWM, "Ended with unexpected sizes %Ix != %x", ptr - bytes, | |
AssertCodeMsg(ptr == (bytes + size), EXCEPTIONCODE_LWM, "Ended with unexpected sizes %Ix != %x", ptr - bytes, |
src/coreclr/jit/codegenarm.cpp
Outdated
@@ -460,7 +460,7 @@ void CodeGen::genLclHeap(GenTree* tree) | |||
} | |||
|
|||
// regCnt will be the total number of bytes to locAlloc | |||
genSetRegToIcon(regCnt, amount, ((int)amount == amount) ? TYP_INT : TYP_LONG); | |||
genSetRegToIcon(regCnt, amount, ((int)amount >= 0) ? TYP_INT : TYP_LONG); |
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.
I don't think this is relevant to CodeGen::instGen_Set_Reg_To_Reloc_Imm
issue in cross-bitness scenarious.
The change is for localloc
(i.e. .NET way of alloca
).
According to ECMA-335
The localloc
instruction allocates size (type native unsigned int
or U4
) bytes from the local
dynamic memory pool ...
I agree with Sergey that we should always use TYP_INT
here.
genSetRegToIcon(regCnt, amount, ((int)amount >= 0) ? TYP_INT : TYP_LONG); | |
genSetRegToIcon(regCnt, amount, TYP_INT); |
@@ -112,10 +112,6 @@ if(CLR_CMAKE_HOST_ARCH_ARM) | |||
endif() | |||
endif(CLR_CMAKE_HOST_ARCH_ARM) | |||
|
|||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
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.
Can you please give an example why the change is needed? Is it assembler related?
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 should stay, but the condition should be updated so that it gets added only for Intel processors (CLR_CMAKE_HOST_ARCH_AMD64 or CLR_CMAKE_HOST_ARCH_I386).
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.
arm assembler doesn't have this option, and linux x64 shows:
$ as --help|grep divide
--divide ignored
Why is this option needed?
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 was added for SunOS support. @am11 do you remember why was it needed?
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.
On SYS-V derivative platforms, /
in assembly is treated as #
rather than division. In context2.S, we are using division, so it breaks build on platforms, such as SunOS-likes and QNX.
Please note that GNU toolchain support is strictly added for community supported platforms in .NET, where LLVM toolchain is either not available or not as complete. If your platform already has good support for LLVM toolchain, it is recommended (per its official support stauts) to use that instead.
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.
Thanks for explanation. I've kept the original GNU condition and added x86/x64 check.
@@ -526,7 +526,7 @@ tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) | |||
break; | |||
|
|||
case UNW_ARM_FRAME_SYSCALL: | |||
printf("XXX1\n"); | |||
//printf("XXX1\n"); |
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.
Would adding #include <stdio.h>
at the beginning of the file fix the issue or it would introduce some other errors?
cc @janvorli
@@ -82,7 +82,7 @@ static const CpuCapability CpuCapabilities[] = { | |||
// If the capability name is not recognized or unused at present, zero is returned. | |||
static unsigned long LookupCpuCapabilityFlag(const char* start, size_t length) | |||
{ | |||
for (int i = 0; i < _countof(CpuCapabilities); i++) | |||
for (int i = 0; i < (int)_countof(CpuCapabilities); i++) |
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.
I would avoid casting
for (int i = 0; i < (int)_countof(CpuCapabilities); i++) | |
for (size_t i = 0; i < _countof(CpuCapabilities); i++) |
d05eb6a
to
7bd8bb6
Compare
Mostly signed/unsigned comparisons, etc.
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.
I see that the PR was updated, LGTM, thanks for making the changes.
Test failures are #53311 |
Mostly signed/unsigned comparisons, etc.
cc @alpencolt