Closed Narutoworld closed 4 years ago
This is because I used an old version of cycle.h from fftw project, should update to the new version which adds support of AARCH64 : https://github.com/FFTW/fftw3/blob/master/kernel/cycle.h
Waiting the patch you can update the file in ./extern-deps/from-fftw/cycle.h
I imported the last version of fftw in the master branch which adds support of AARCH64, can you confirm it fixes your issue ?
I update the file and redo the cmake steps, it seems the errors are still there.
Scanning dependencies of target malt-core
[ 2%] Building CXX object src/lib/core/CMakeFiles/malt-core.dir/VmaTracker.cpp.o
[ 2%] Building CXX object src/lib/core/CMakeFiles/malt-core.dir/SymbolSolver.cpp.o
[ 3%] Building CXX object src/lib/core/CMakeFiles/malt-core.dir/CallStackInfo.cpp.o
In file included from /home/b84170347/malt-master/src/lib/core/CallStackInfo.cpp:15:0:
/home/userid/malt-master/src/lib/core/CallStackInfo.hpp:62:40: error: ‘ticks’ has not been declared
void onFreeLinkedMemory(size_t value,ticks lifetime,size_t peakId);
^~~~~
/home/userid/malt-master/src/lib/core/CallStackInfo.cpp:166:54: error: ‘ticks’ has not been declared
void CallStackInfo::onFreeLinkedMemory(size_t value, ticks lifetime,size_t peakId)
^~~~~
make[2]: *** [src/lib/core/CMakeFiles/malt-core.dir/build.make:89: src/lib/core/CMakeFiles/malt-core.dir/CallStackInfo.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:305: src/lib/core/CMakeFiles/malt-core.dir/all] Error 2
Can I ask you to play a bit with #error
in the last three #if
of cycle.h to see if you enter in one case ?
Also on which version of ARM are you compiling ? V7/V8 ?
According to /proc/cpuinfo, it should be ARM V8.( CPU architecture: 8
)
Since it keeps complaining about ticks
has not been declared, I just remove those #if defined(__aarch64__) && defined(HAVE_ARMV8_PMCCNTR_EL0)
header to force it fall into one of the cases and receive redefinition of ticks getticks()
error
In file included from /home/userid/malt-master/src/lib/core/CallStackInfo.hpp:17:0,
from /home/userid/malt-master/src/lib/core/SimpleCallStackNode.hpp:13,
from /home/userid/malt-master/src/lib/core/SegmentTracker.hpp:19,
from /home/userid/malt-master/src/lib/core/SegmentTracker.cpp:13:
/home/userid/malt-master/src/lib/../../extern-deps/from-fftw/cycle.h: In function ‘ticks getticks()’:
/home/userid/malt-master/src/lib/../../extern-deps/from-fftw/cycle.h:556:21: error: redefinition of ‘ticks getticks()’
static inline ticks getticks(void)
^~~~~~~~
In file included from /home/userid/malt-master/src/lib/core/SegmentTracker.hpp:16:0,
from /home/userid/malt-master/src/lib/core/SegmentTracker.cpp:13:
/home/userid/malt-master/src/lib/../../extern-deps/from-fftw/cycle.h:556:21: note: ‘ticks getticks()’ previously defined here
static inline ticks getticks(void)
^~~~~~~~
In file included from /home/userid/malt-master/src/lib/core/CallStackInfo.hpp:17:0,
from /home/userid/malt-master/src/lib/core/SimpleCallStackNode.hpp:13,
from /home/userid/malt-master/src/lib/core/SegmentTracker.hpp:19,
from /home/userid/malt-master/src/lib/core/SegmentTracker.cpp:13:
/home/userid/malt-master/src/lib/../../extern-deps/from-fftw/cycle.h: In function ‘double elapsed(ticks, ticks)’:
/home/userid/malt-master/src/lib/../../extern-deps/from-fftw/cycle.h:92:47: error: redefinition of ‘double elapsed(ticks, ticks)’
#define INLINE_ELAPSED(INL) static INL double elapsed(ticks t1, ticks t0) \
^
/home/b84170347/malt-master/src/lib/../../extern-deps/from-fftw/cycle.h:562:1: note: in expansion of macro ‘INLINE_ELAPSED’
INLINE_ELAPSED(inline)
^~~~~~~~~~~~~~
In file included from /home/b84170347/malt-master/src/lib/core/SegmentTracker.hpp:16:0,
from /home/b84170347/malt-master/src/lib/core/SegmentTracker.cpp:13:
/home/userid/malt-master/src/lib/../../extern-deps/from-fftw/cycle.h:92:47: note: ‘double elapsed(ticks, ticks)’ previously defined here
#define INLINE_ELAPSED(INL) static INL double elapsed(ticks t1, ticks t0) \
^
/home/userid/malt-master/src/lib/../../extern-deps/from-fftw/cycle.h:562:1: note: in expansion of macro ‘INLINE_ELAPSED’
INLINE_ELAPSED(inline)
^~~~~~~~~~~~~~
make[2]: *** [src/lib/core/CMakeFiles/malt-core.dir/build.make:115: src/lib/core/CMakeFiles/malt-core.dir/SegmentTracker.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:305: src/lib/core/CMakeFiles/malt-core.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
I have check the gcc/g++ compiler on my machine, they did not define any MACRO such as HAVE_ARMV8_CNTVCT_EL0
or HAVE_ARMV8_PMCCNTR_EL0
.
You need to replace the #if defined(__aarch64__) && defined(HAVE_ARMV8_PMCCNTR_EL0)
by #ifndef HAVE_TICK_COUNTER
to avoid redefinition if included multiple times. Maybe it should pass.
I think I have to detect and define the HAVE_... myself in the cmake script.
If ever you have time to test I made the detection in branch fix/57-aarch64-asm-detection
.
The automatic detection does not work well. But with mannually editing the files, I made it compile on my machine.
I checked and comfired, the second last case works on my machine and force the complier fall into that category with removing those checking MACRO. Also I have to do #include<stdint.h>
to let the gcc compiler recognize uint64_t
type.
#if defined(__aarch64__) && !defined(HAVE_TICK_COUNTER)
#include <stdint.h>
typedef uint64_t ticks;
static inline ticks getticks(void)
{
uint64_t Rt;
asm volatile("mrs %0, CNTVCT_EL0" : "=r" (Rt));
return Rt;
}
INLINE_ELAPSED(inline)
#define HAVE_TICK_COUNTER
#endif
Comment 1: Is there a btter place to include <stdint.h>
or using long long
to replace uint64_t.
For Automatic detection parts.
In src/lib/CMakeLists.txt
, I revise the syntax of check compilation by using CheckCSourceRuns
FYI, the last 4 cases are ARM related, I include them here
# check arm execution
include(CheckCSourceRuns)
CHECK_C_SOURCE_RUNS("int main() {long Rt, Rt2 = 0; asm volatile(\"mrrc p15, 1, %0, %1, c14\" : \"=r\"(Rt), \"=r\"(Rt2)); return 0;}" HAVE_ARMV7A_CNTVCT)
CHECK_C_SOURCE_RUNS("int main() {lont r; asm volatile(\"mrc p15, 0, %0, c9, c13, 0\" : \"=r\"(r) ); return 0;}" HAVE_ARMV7A_PMCCNTR)
CHECK_C_SOURCE_RUNS("int main() {long long Rt; asm volatile(\"mrs %0, CNTVCT_EL0\" : \"=r\" (Rt)); return 0;}" HAVE_ARMV8_CNTVCT_EL0)
CHECK_C_SOURCE_RUNS("int main() {long long cc; asm volatile(\"mrs %0, PMCCNTR_EL0\" : \"=r\"(cc)); return 0;}" HAVE_ARMV8_PMCCNTR_EL0)
Comment 2: asm volatile(\"mrs %0, PMCCNTR_EL0\" : \"=r\"(cc)); return 0;}
succeeds in compilation but fails in execution. So I decide to use CheckCSourceRuns.
And add one more cmakedefine
in the corresponding part in src/lib/config.h.in
//arm RDTSC port selection
#cmakedefine HAVE_ARMV7A_CNTVCT
#cmakedefine HAVE_ARMV7A_PMCCNTR
#cmakedefine HAVE_ARMV8_CNTVCT_EL0
#cmakedefine HAVE_ARMV8_PMCCNTR_EL0
Comment 3: With the chages above, I have seen there are 3 failed
1 success
(Excepted Behavior)
-- Performing Test HAVE_ARMV7A_CNTVCT
-- Performing Test HAVE_ARMV7A_CNTVCT - Failed
-- Performing Test HAVE_ARMV7A_PMCCNTR
-- Performing Test HAVE_ARMV7A_PMCCNTR - Failed
-- Performing Test HAVE_ARMV8_CNTVCT_EL0
-- Performing Test HAVE_ARMV8_CNTVCT_EL0 - Success
-- Performing Test HAVE_ARMV8_PMCCNTR_EL0
-- Performing Test HAVE_ARMV8_PMCCNTR_EL0 - Failed
But the build process is still broken, with
/home/malt-fix-57-aarch64-asm-detection/src/lib/core/CallStackInfo.hpp:62:40: error: ‘ticks’ has not been declared
void onFreeLinkedMemory(size_t value,ticks lifetime,size_t peakId);
^~~~~
/homemalt-fix-57-aarch64-asm-detection/src/lib/core/CallStackInfo.cpp:166:54: error: ‘ticks’ has not been declared
void CallStackInfo::onFreeLinkedMemory(size_t value, ticks lifetime,size_t peakId)
It seems the HAVE_ARMV8_CNTVCT_EL0
has not been defined (I revert my manual changes)
Although I have seen its defination in /home/userid/malt-fix-57-aarch64-asm-detection/build/src/lib/config.h
//arm RDTSC port selection
/* #undef HAVE_ARMV7A_CNTVCT */
/* #undef HAVE_ARMV7A_PMCCNTR */
#define HAVE_ARMV8_CNTVCT_EL0
/* #undef HAVE_ARMV8_PMCCNTR_EL0 */
I guess that is related to the order of including? Can you check this issues?
Thanks for all the materials, I will give a look tomorrow, this might be because config.h is not included before inclusion of cycle.h.
If you have time you can try to #include <config.h>
in the faulting files.
I made a patch to introduce your fixes and tested build in a qemu-arm machine. It should work now. If ever you have a bit of time to test and confirm.
Branch #57 works on the aarch64 machine. Thanks
Try to compile the source on an aarch64 architecture with CentOS (RPM Package Manager) installed environment, and find the following error: