LLVM11 debug info is different from LLVM8 debug info when running the same compilation command - clang

The C source code is as following.
#include "fdlibm.h"
#include <errno.h>
#ifdef __STDC__
double ldexp(double value, int exp)
#else
double ldexp(value, exp)
double value; int exp;
#endif
{
if(!finite(value)||value==0.0) return value;
value = scalbn(value,exp);
if(!finite(value)||value==0.0) errno = ERANGE;
return value;
}
The compilation command is "clang -emit-llvm -g -O3 -D_IEEE_LIBM -Wall -Wuninitialized -c s_ldexp.c -o s_ldexp.bc"
I transform the bitcode into human-readable LLVM assembly language using this command "llvm-dis s_ldexp.bc -o s_ldexp.ll"
The IR compiled by clang8 is as following.
; ModuleID = 's_ldexp.llvm8.O3.bc'
source_filename = "s_ldexp.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define dso_local double #ldexp(double, i32) local_unnamed_addr #0 !dbg !7 {
call void #llvm.dbg.value(metadata double %0, metadata !13, metadata !DIExpression()), !dbg !15
call void #llvm.dbg.value(metadata i32 %1, metadata !14, metadata !DIExpression()), !dbg !16
%3 = tail call double #llvm.fabs.f64(double %0) #4, !dbg !17
%4 = fcmp ueq double %3, 0x7FF0000000000000, !dbg !17
%5 = fcmp oeq double %0, 0.000000e+00, !dbg !19
%6 = or i1 %5, %4, !dbg !20
br i1 %6, label %15, label %7, !dbg !20
; <label>:7: ; preds = %2
%8 = tail call double #scalbn(double %0, i32 %1) #5, !dbg !21
call void #llvm.dbg.value(metadata double %8, metadata !13, metadata !DIExpression()), !dbg !15
%9 = tail call double #llvm.fabs.f64(double %8) #4, !dbg !22
%10 = fcmp ueq double %9, 0x7FF0000000000000, !dbg !22
%11 = fcmp oeq double %8, 0.000000e+00, !dbg !24
%12 = or i1 %11, %10, !dbg !25
br i1 %12, label %13, label %15, !dbg !25
; <label>:13: ; preds = %7
%14 = tail call i32* #__errno_location() #6, !dbg !26
store i32 34, i32* %14, align 4, !dbg !27, !tbaa !28
br label %15, !dbg !26
; <label>:15: ; preds = %13, %7, %2
%16 = phi double [ %0, %2 ], [ %8, %7 ], [ %8, %13 ], !dbg !32
ret double %16, !dbg !33
}
; Function Attrs: nounwind readnone speculatable
declare double #llvm.fabs.f64(double) #1
; Function Attrs: nounwind
declare dso_local double #scalbn(double, i32) local_unnamed_addr #2
; Function Attrs: nounwind readnone
declare dso_local i32* #__errno_location() local_unnamed_addr #3
; Function Attrs: nounwind readnone speculatable
declare void #llvm.dbg.value(metadata, metadata, metadata) #1
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable }
attributes #2 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { readnone }
attributes #5 = { nounwind }
attributes #6 = { nounwind readnone }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0 (tags/RELEASE_800/final)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
!1 = !DIFile(filename: "s_ldexp.c", directory: "/root/test/ficl/fdlibm53")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 8.0.0 (tags/RELEASE_800/final)"}
!7 = distinct !DISubprogram(name: "ldexp", scope: !1, file: !1, line: 18, type: !8, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10, !11}
!10 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !{!13, !14}
!13 = !DILocalVariable(name: "value", arg: 1, scope: !7, file: !1, line: 18, type: !10)
!14 = !DILocalVariable(name: "exp", arg: 2, scope: !7, file: !1, line: 18, type: !11)
!15 = !DILocation(line: 18, column: 22, scope: !7)
!16 = !DILocation(line: 18, column: 33, scope: !7)
!17 = !DILocation(line: 24, column: 6, scope: !18)
!18 = distinct !DILexicalBlock(scope: !7, file: !1, line: 24, column: 5)
!19 = !DILocation(line: 24, column: 26, scope: !18)
!20 = !DILocation(line: 24, column: 19, scope: !18)
!21 = !DILocation(line: 25, column: 10, scope: !7)
!22 = !DILocation(line: 26, column: 6, scope: !23)
!23 = distinct !DILexicalBlock(scope: !7, file: !1, line: 26, column: 5)
!24 = !DILocation(line: 26, column: 26, scope: !23)
!25 = !DILocation(line: 26, column: 19, scope: !23)
!26 = !DILocation(line: 26, column: 33, scope: !23)
!27 = !DILocation(line: 26, column: 39, scope: !23)
!28 = !{!29, !29, i64 0}
!29 = !{!"int", !30, i64 0}
!30 = !{!"omnipotent char", !31, i64 0}
!31 = !{!"Simple C/C++ TBAA"}
!32 = !DILocation(line: 0, scope: !7)
!33 = !DILocation(line: 28, column: 1, scope: !7)
The IR compiled by clang11 is as following.
; ModuleID = 's_ldexp.llvm11.O3.bc'
source_filename = "s_ldexp.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define dso_local double #ldexp(double %0, i32 %1) local_unnamed_addr #0 !dbg !7 {
call void #llvm.dbg.value(metadata double %0, metadata !13, metadata !DIExpression()), !dbg !15
call void #llvm.dbg.value(metadata i32 %1, metadata !14, metadata !DIExpression()), !dbg !15
%3 = tail call double #llvm.fabs.f64(double %0) #4, !dbg !16
%4 = fcmp ueq double %3, 0x7FF0000000000000, !dbg !16
%5 = fcmp oeq double %0, 0.000000e+00
%6 = or i1 %5, %4, !dbg !18
br i1 %6, label %15, label %7, !dbg !18
7: ; preds = %2
%8 = tail call double #scalbn(double %0, i32 %1) #5, !dbg !19
call void #llvm.dbg.value(metadata double %8, metadata !13, metadata !DIExpression()), !dbg !15
%9 = tail call double #llvm.fabs.f64(double %8) #4, !dbg !20
%10 = fcmp ueq double %9, 0x7FF0000000000000, !dbg !20
%11 = fcmp oeq double %8, 0.000000e+00
%12 = or i1 %11, %10, !dbg !22
br i1 %12, label %13, label %15, !dbg !22
13: ; preds = %7
%14 = tail call i32* #__errno_location() #6, !dbg !23
store i32 34, i32* %14, align 4, !dbg !24, !tbaa !25
br label %15, !dbg !23
15: ; preds = %13, %7, %2
%16 = phi double [ %0, %2 ], [ %8, %7 ], [ %8, %13 ], !dbg !15
ret double %16, !dbg !29
}
; Function Attrs: nounwind readnone speculatable willreturn
declare double #llvm.fabs.f64(double) #1
; Function Attrs: nounwind
declare dso_local double #scalbn(double, i32) local_unnamed_addr #2
; Function Attrs: nounwind readnone
declare dso_local i32* #__errno_location() local_unnamed_addr #3
; Function Attrs: nounwind readnone speculatable willreturn
declare void #llvm.dbg.value(metadata, metadata, metadata) #1
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable willreturn }
attributes #2 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { readnone }
attributes #5 = { nounwind }
attributes #6 = { nounwind readnone }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 0160ad802e899c2922bc9b29564080c22eb0908c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "s_ldexp.c", directory: "/root/test/ficl/fdlibm53")
!2 = !{}
!3 = !{i32 7, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 0160ad802e899c2922bc9b29564080c22eb0908c)"}
!7 = distinct !DISubprogram(name: "ldexp", scope: !1, file: !1, line: 18, type: !8, scopeLine: 23, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10, !11}
!10 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !{!13, !14}
!13 = !DILocalVariable(name: "value", arg: 1, scope: !7, file: !1, line: 18, type: !10)
!14 = !DILocalVariable(name: "exp", arg: 2, scope: !7, file: !1, line: 18, type: !11)
!15 = !DILocation(line: 0, scope: !7)
!16 = !DILocation(line: 24, column: 6, scope: !17)
!17 = distinct !DILexicalBlock(scope: !7, file: !1, line: 24, column: 5)
!18 = !DILocation(line: 24, column: 19, scope: !17)
!19 = !DILocation(line: 25, column: 10, scope: !7)
!20 = !DILocation(line: 26, column: 6, scope: !21)
!21 = distinct !DILexicalBlock(scope: !7, file: !1, line: 26, column: 5)
!22 = !DILocation(line: 26, column: 19, scope: !21)
!23 = !DILocation(line: 26, column: 33, scope: !21)
!24 = !DILocation(line: 26, column: 39, scope: !21)
!25 = !{!26, !26, i64 0}
!26 = !{!"int", !27, i64 0}
!27 = !{!"omnipotent char", !28, i64 0}
!28 = !{!"Simple C/C++ TBAA"}
!29 = !DILocation(line: 28, column: 1, scope: !7)
In the s_ldexp.c, there one code snippet “value==0.0”.
The corresponding IR compiled by clang8 is "%5 = fcmp oeq double %0, 0.000000e+00, !dbg !19".
The corresponding IR compiled by clang11 is "%5 = fcmp oeq double %0, 0.000000e+00".
Compared with clang8, the debug info "!dbg !19" is missing in the corresponding IR compiled by clang11. The debug info is important to me. I hope that LLVM11 can reserve the debug info. For LLVM11, there are there methods that can solve the problem.
The first method is to run these two commands.
clang -emit-llvm -O3 -D_IEEE_LIBM -Wall -Wuninitialized -c s_ldexp.c -o s_ldexp.bc
opt -enable-debugify s_ldexp.bc -o s_ldexp.debug.bc
When using clang to compile source code, "-g" parameter is not used. And we can use llvm opt command to attach debug info into the IR.
The second method is to run this command.
clang -emit-llvm -g -O0 -D_IEEE_LIBM -Wall -Wuninitialized -c s_ldexp.c -o s_ldexp.bc
The command is to lower the optimization level of compiler and keep as much debug info as possible.
The third method is to modify the C source code.
The code after modification is as following.
#include "fdlibm.h"
#include <errno.h>
#include <stdbool.h>
#ifdef __STDC__
double ldexp(double value, int exp)
#else
double ldexp(value, exp)
double value; int exp;
#endif
{
bool flag1 = (!finite(value)) || (value==0.0);
if(flag1) return value;
value = scalbn(value,exp);
bool flag2 = (!finite(value)) || (value==0.0);
if(flag2) errno = ERANGE;
return value;
}
We can get around this problem using the third method.
Though these three method can solve this problem, I still have two questions.
The first question is why the debug info is missing in the IR compiled by clang11.
The second question is that is there any option or LLVM pass can check whether some debug info is missing and complement the missing debug info.

Related

Array access and assignment has variable alignment size in LLVM IR output generated by clang

Hey I'm working on a project where I'm creating a compiler.
While trying to implement array element assignment I ran into this piece of llvm ir code:
define dso_local i32 #main() {
%1 = alloca [10 x i32], align 16
%2 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32 2, i32* %2, align 16
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 4, i32* %3, align 4
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
store i32 6, i32* %4, align 8
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
store i32 8, i32* %5, align 4
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 10, i32* %6, align 16
ret i32 0
}
Generated from:
int main () {
int x[10];
x[0] = 2;
x[1] = 4;
x[2] = 6;
x[3] = 8;
x[4] = 10;
}
While inspecting the IR output, I noticed that the alignment always seems to be different (16-4-8-4). I am quite puzzled by this, and don't know why the alignment would be variable. Any hints or nudges in the right directions would be much appreciated.
Clang seems to be using its knowledge of the alloca's alignment and the pointer offsets to compute the maximum alignment of each element individually. The alloca is aligned to 16B, so a pointer to element 0 (no offset) will have that alignment. But since the elements in the array in the alloca are only 4B in size (i32), which is less than 16B, the pointer alignment changes once you offset it to get later elements.
Clang could just set the alignment on everything here to be 4 instead, but there's no rule that requires it to. Moreover there can be some benefits to using this large alignment of 16 for the array, such as enabling 4 elements (4 × 4B = 16B) to be loaded at once with a SIMD instruction.

How does Clang compute indices of GEP instructions in virtual tables when compiling virtual inheritance classes in C++?

I'm trying to understand the way Clang compiles virtual inheritance classes in C++. Here is my code:
// test.cpp
#include <stdio.h>
int global_obj;
int *global_ptr = &global_obj;
class A {
public:
virtual int f(int *i) { return *i; }
};
class B: virtual public A { // class B is virtual inheritance class of A
};
int main(int argc, char **argv)
{
int *ptr = &global_obj;
B *pb = new B;
int a = pb->f(ptr);
return a;
}
My compilation command is:
clang -O0 -Xclang -disable-llvm-passes -Xclang -disable-O0-optnone -c -emit-llvm test.c
opt -mem2reg test.bc
and below is the compiled LLVM bitcode, where _ZN1BC1Ev and _ZN1AC2Ev are the compiled constructors of class B and A.
%class.B = type { %class.A }
%class.A = type { i32 (...)** }
#global_obj = global i32 0, align 4
#global_ptr = global i32* #global_obj, align 8
#_ZTV1B = linkonce_odr unnamed_addr constant { [5 x i8*] } { [5 x i8*] [i8* null, i8* null, i8* null, i8* null, i8* bitcast (i32 (%class.A*, i32*)* #_ZN1A1fEPi to i8*)] }, align 8
#_ZTT1B = linkonce_odr unnamed_addr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* #_ZTV1B, i32 0, inrange i32 0, i32 4) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* #_ZTV1B, i32 0, inrange i32 0, i32 4) to i8*)], align 8
#_ZTV1A = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%class.A*, i32*)* #_ZN1A1fEPi to i8*)] }, align 8
; Function Attrs: noinline norecurse ssp uwtable
define i32 #main(i32, i8**) #0 {
%3 = call i8* #_Znwm(i64 8) #3
%4 = bitcast i8* %3 to %class.B*
call void #_ZN1BC1Ev(%class.B* %4) #4
%5 = bitcast %class.B* %4 to i8**
%6 = load i8*, i8** %5, align 8
%7 = getelementptr i8, i8* %6, i64 -32
%8 = bitcast i8* %7 to i64*
%9 = load i64, i64* %8, align 8
%10 = bitcast %class.B* %4 to i8*
%11 = getelementptr inbounds i8, i8* %10, i64 %9
%12 = bitcast i8* %11 to %class.A*
%13 = bitcast %class.A* %12 to i32 (%class.A*, i32*)***
%14 = load i32 (%class.A*, i32*)**, i32 (%class.A*, i32*)*** %13, align 8
%15 = getelementptr inbounds i32 (%class.A*, i32*)*, i32 (%class.A*, i32*)** %14, i64 0
%16 = load i32 (%class.A*, i32*)*, i32 (%class.A*, i32*)** %15, align 8
%17 = call i32 %16(%class.A* %12, i32* #global_obj)
ret i32 %17
}
; Function Attrs: nobuiltin
declare noalias i8* #_Znwm(i64) #1
; Function Attrs: noinline nounwind ssp uwtable
define linkonce_odr void #_ZN1BC1Ev(%class.B*) unnamed_addr #2 align 2 {
%2 = bitcast %class.B* %0 to %class.A*
call void #_ZN1AC2Ev(%class.A* %2) #4
%3 = bitcast %class.B* %0 to i32 (...)***
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* #_ZTV1B, i32 0, inrange i32 0, i32 4) to i32 (...)**), i32 (...)*** %3, align 8
%4 = bitcast %class.B* %0 to i32 (...)***
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* #_ZTV1B, i32 0, inrange i32 0, i32 4) to i32 (...)**), i32 (...)*** %4, align 8
ret void
}
; Function Attrs: noinline nounwind ssp uwtable
define linkonce_odr void #_ZN1AC2Ev(%class.A*) unnamed_addr #2 align 2 {
%2 = bitcast %class.A* %0 to i32 (...)***
store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* #_ZTV1A, i32 0, inrange i32 0, i32 2) to i32 (...)**), i32 (...)*** %2, align 8
ret void
}
; Function Attrs: noinline nounwind ssp uwtable
define linkonce_odr i32 #_ZN1A1fEPi(%class.A*, i32*) unnamed_addr #2 align 2 {
%3 = load i32, i32* %1, align 4
ret i32 %3
}
I understand that Clang will introduce a virtual table to capture objects of the classes A and B.
But when delving deeper into the compilation of the main function, I don't really understand why Clang introduces a GEP of index -32 in the main function.
And what is the value of index %9 in the next GEP. Why can't it be determined at compile time?
%7 = getelementptr i8, i8* %6, i64 -32
%8 = bitcast i8* %7 to i64*
%9 = load i64, i64* %8, align 8
%10 = bitcast %class.B* %4 to i8*
%11 = getelementptr inbounds i8, i8* %10, i64 %9
Does anyone know why Clang does so?
Thank you very much for reading my very long question!
Location of virtually inherited base class can not be determined at compile-time and is delayed until runtime. The virtual base offset (vbase offset) is located within the vtable so first your code loads the vtable pointer:
%5 = bitcast %class.B* %4 to i8**
%6 = load i8*, i8** %5, align 8
and then loads the vbase offset (from pre-defined location at vptr - 32):
%7 = getelementptr i8, i8* %6, i64 -32
%8 = bitcast i8* %7 to i64*
%9 = load i64, i64* %8, align 8
This is used to compute the offset to base class:
%10 = bitcast %class.B* %4 to i8*
%11 = getelementptr inbounds i8, i8* %10, i64 %9
%12 = bitcast i8* %11 to %class.A*
and load pointer to virtual method from base class's vtable:
%13 = bitcast %class.A* %12 to i32 (%class.A*, i32*)***
%14 = load i32 (%class.A*, i32*)**, i32 (%class.A*, i32*)*** %13, align 8
%15 = getelementptr inbounds i32 (%class.A*, i32*)*, i32 (%class.A*, i32*)** %14, i64 0
%16 = load i32 (%class.A*, i32*)*, i32 (%class.A*, i32*)** %15, align 8
and finally call it:
%17 = call i32 %16(%class.A* %12, i32* #global_obj)
You can find more details on how vtables are organized in Itanium ABI (but beware that it's not for the faint-hearted).

Error when trying to generate simple apk on Kivy Complete VM

Windows 10 x64
VirtualBox 6.1
Kivy Complete VM 0.7
I'm trying to generate a simple apk file and it always returns errors, I've tried to delete the virtual machine and create it again, thinking it was the result of some configuration done previously by me. I'm new to programming, I don't find that same mistake on the internet and I don't know how to solve it.
The code in "/home/kivy/Desktop/teste/main.py":
from kivy.app import App
from kivy.uix.button import Button
class MyApp(App):
def build(self):
return Button(text='Hello World')
MyApp().run()
The commands in "/home/kivy/Desktop/teste":
buildozer init
buildozer -v android debug
Some things that return:
[INFO]: Trying first build of pyjnius to get cython files: this is expected to fail
[INFO]: -> running python3 setup.py build_ext -v
Exception in thread background thread for pid 3232:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v
STDOUT:
warning: [options] bootstrap class path not set in conjunction with -source 7
1 warning
running build_ext
building 'jnius' extension
creating build
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/jnius
/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include -DANDROID -D__ANDROID_API__=21 -I/home/kivy/.buildozer/android/platform/android-ndk-r19b/sysroot/usr/include/arm-linux-androideabi -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/include/python3.8 -fPIC -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Include -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build -c jnius/jnius.c -o build/temp.linux-x86_64-3.8/jnius/jnius.o
clang: error: no such file or directory: 'jnius/jnius.c'
clang: error: no input files
error: command '/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit status 1
STDERR:
[INFO]: pyjnius first build failed (as expected)
[INFO]: Running cython where appropriate
[INFO]: Cythonize jnius/jnius.pyx
[INFO]: -> running python3 -m Cython.Build.Cythonize ./jnius/jnius.pyx
[INFO]: -> running python3 setup.py build_ext -v
working: error: command '/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit status 1 Exception in thread background thread for pid 3263:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v
STDOUT:
warning: [options] bootstrap class path not set in conjunction with -source 7
1 warning
running build_ext
building 'jnius' extension
/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include -DANDROID -D__ANDROID_API__=21 -I/home/kivy/.buildozer/android/platform/android-ndk-r19b/sysroot/usr/include/arm-linux-androideabi -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/include/python3.8 -fPIC -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Include -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build -c jnius/jnius.c -o build/temp.linux-x86_64-3.8/jnius/jnius.o
jnius/jnius.c:3738:89: warning: incompatible pointer types passing 'JNIEnv **'
(aka 'const struct JNINativeInterface_ ***') to parameter of type
'void **' [-Wincompatible-pointer-types]
...(&__pyx_v_env), NULL));
^~~~~~~~~~~~~~
jnius/jnius.c:10723:19: warning: assigning to 'jchar *' (aka 'unsigned short *')
from 'const jchar *' (aka 'const unsigned short *') discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
...= (__pyx_v_j_env[0])->GetStringChars(__pyx_v_j_env, __pyx_v_j_string, NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:20421:30: warning: incompatible pointer types assigning to
'jobject' (aka 'struct _jobject *') from 'jobject *' (aka
'struct _jobject **'); dereference with * [-Wincompatible-pointer-types]
(__pyx_v_jargs[0]) = ((jobject *)__pyx_v_classLoader);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*( )
jnius/jnius.c:20430:30: warning: incompatible pointer types assigning to
'jobject' (aka 'struct _jobject *') from 'jclass *' (aka
'struct _jobject **'); dereference with * [-Wincompatible-pointer-types]
(__pyx_v_jargs[1]) = __pyx_v_interfaces;
^ ~~~~~~~~~~~~~~~~~~
*
jnius/jnius.c:35645:36: warning: assigning to 'char *' from 'const char *'
discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
(__pyx_v_invoke_methods[0]).name = ((char const *)"invoke0");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:35654:41: warning: assigning to 'char *' from 'const char *'
discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
...= ((char const *)"(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:51997:258: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_env_pxi, __pyx_n_s_detach, 23, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52009:261: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_func_pxi, __pyx_n_s_cast, 4, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52021:272: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_func_pxi, __pyx_n_s_find_javaclass, 17, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52033:263: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(5, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_init, 11, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52048:273: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_instancecheck, 43, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52060:263: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(4, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_new, 113, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52072:273: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_subclasscheck, 119, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52084:273: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_get_javaclass, 148, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52096:274: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_resolve_class, 152, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52108:280: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_init, 1051, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52120:280: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_init, 1057, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52140:255: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__84, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_proxy_pxi, __pyx_n_s_init, 2, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52155:256: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_proxy_pxi, __pyx_n_s_get_2, 7, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52167:256: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_proxy_pxi, __pyx_n_s_call, 10, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52232:259: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__96, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:57497:9: error: too many arguments to function call, expected 15,
have 16
__pyx_empty_bytes /*PyObject *lnotab*/
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
6 warnings and 16 errors generated.
error: command '/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit status 1
STDERR:
[INFO]: STDOUT (last 20 lines of 213):
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:57497:9: error: too many arguments to function call, expected 15,
have 16
__pyx_empty_bytes /*PyObject *lnotab*/
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
6 warnings and 16 errors generated.
error: command '/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit status 1
[INFO]: STDERR:
[INFO]: COMMAND:
cd /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/pyjnius-python3-sdl2/armeabi-v7a__ndk_target_21/pyjnius && /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v
[WARNING]: ERROR: /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 failed!
Thanks in advance.
EDIT: Problem solved with another VM
Had the same issue on my Ubuntu 16.04 machine. Settings:
Virtual Environment with python=3.6.3
Kivy=1.11.1
Setup buildozer from master (b566125f71edc82b53ac0249ca710ff8fd4fea54)
Installed compatible Cython=0.29.9 as mentioned here
Solved the problem by updating to the latest Cython version (0.29.16 for me):
pip install --upgrade Cython
It seems like you don't have cython or something is wrong with cython. Consider installing it with the command mentioned from alexmazurik

How can i input boolean tensors to tf.cond() not just one boolean?

Here is what I want to implement f(x) with tensorflow
input x = (x1,x2,x3,x4,x5,x6,x7,x8,x9)
define f(x) = f1(x1,x2,x3,x4,x5) + f2(x5,x6,x7,x8,x9)
where
f1(x1,x2,x3,x4,x5) = {1 if
(x1,x2,x3,x4,x5)=(0,0,0,0,0),
g1(x1,x2,x3,x4,x5) otherwise}
f2(x5,x6,x7,x8,x9) = {1 if
(x5,x6,x7,x8,x9)=(0,0,0,0,0),
g2(x5,x6,x7,x8,x9) otherwise}
This is my tensorflow code
import tensorflow as tf
import numpy as np
ph = tf.placeholder(dtype=tf.float32, shape=[None, 9])
x1 = tf.slice(ph, [0, 0], [-1, 5])
x2 = tf.slice(ph, [0, 4], [-1, 5])
fixed1 = tf.placeholder(dtype=tf.float32, shape=[1, 5])
fixed2 = tf.placeholder(dtype=tf.float32, shape=[1, 5])
# MLP 1
w1 = tf.Variable(tf.ones([5, 1]))
g1 = tf.matmul(x1, w1)
# MLP 2
w2 = tf.Variable(-tf.ones([5, 1]))
g2 = tf.matmul(x2, w2)
check1 = tf.reduce_all(tf.equal(x1, fixed1), axis=1, keep_dims=True)
check2 = tf.reduce_all(tf.equal(x2, fixed2), axis=1, keep_dims=True)
#### with Problem
f1 = tf.cond(check1,
lambda: tf.constant([2], dtype=tf.float32), lambda: g1)
f2 = tf.cond(check2,
lambda: tf.constant([1], dtype=tf.float32), lambda: g2)
####
f = tf.add(f1, f2)
x = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 0, 0, 0, 0, 0],
[9, 0, 0, 0, 0, 0, 0, 0, 0]])
fixed = np.array([[0, 0, 0, 0, 0]])
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print('(1)\n', sess.run(check1, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
print('(2)\n', sess.run(check2, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
print('(3)\n', sess.run(f, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
print('(4)\n', sess.run(f1, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
print('(5)\n', sess.run(f2, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
In this case,
check1 is [[ True], [ True], [False], [False], [False]] with shape (5, 1)
check2 is [[ True], [False], [ True], [ True], [ True]] with shape (5, 1)
I expect result of f is [[3], [1], [2], [3], [10]]
but seems like tf.cond() can not handle input as boolean tensors with shape (5, 1)
Could you advice how to implement f(x) with tensorflow, please.
This is Error message what i received
Traceback (most recent call last): File
"C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py",
line 670, in _call_cpp_shape_fn_impl
status) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\contextlib.py",
line 66, in exit
next(self.gen) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py",
line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape
must be rank 0 but is rank 2 for 'cond/Switch' (op: 'Switch') with
input shapes: [?,1], [?,1].
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:/Users/hong/Dropbox/MLILAB/Research/GM-MLP/code/tensorflow_cond.py",
line 23, in
lambda: tf.constant([2], dtype=tf.float32), lambda: g1) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\ops\control_flow_ops.py",
line 1765, in cond
p_2, p_1 = switch(pred, pred) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\ops\control_flow_ops.py",
line 318, in switch
return gen_control_flow_ops._switch(data, pred, name=name) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_control_flow_ops.py",
line 368, in _switch
result = _op_def_lib.apply_op("Switch", data=data, pred=pred, name=name) File
"C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py",
line 759, in apply_op
op_def=op_def) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py",
line 2242, in create_op
set_shapes_for_outputs(ret) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py",
line 1617, in set_shapes_for_outputs
shapes = shape_func(op) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py",
line 1568, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py",
line 610, in call_cpp_shape_fn
debug_python_shape_fn, require_shape_fn) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py",
line 675, in _call_cpp_shape_fn_impl
raise ValueError(err.message) ValueError: Shape must be rank 0 but is rank 2 for 'cond/Switch' (op: 'Switch') with input shapes: [?,1],
[?,1].
Process finished with exit code 1
I think you need tf.where, not tf.cond.
See the answer to this question: How to use tf.cond for batch processing

Clang disable inlining getelementptr

I have the following simple c code.
int a[2] = {1,2};
int main(){
return a[0];
}
Now the IR that clang generates for this case is as follows.
%retval = alloca i32, align 4
store i32 0, i32* %retval, align 4
%0 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* #a, i64 0, i64 0), align 4
ret i32 %0
As seen, the getelementptr instruction is inlined inside of the load instruction. Is there a way to disable this inlining in clang? I'm using clang version 3.8.0.

Resources