diff options
| author | Ross Burton <ross.burton@arm.com> | 2024-10-10 17:06:16 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-10-11 12:17:03 +0100 |
| commit | 91ba10c7a30e2363e6fc96c2b982f6686e94ab00 (patch) | |
| tree | 43e5726fdf5f09771cff6b6559aff05e7cf50f29 /meta/lib/oe | |
| parent | 5e2787fe6dc2d28267ab51c480d45a0c1b4d9a64 (diff) | |
| download | poky-91ba10c7a30e2363e6fc96c2b982f6686e94ab00.tar.gz | |
oe/elf: don't regenerate machine data on every call
Every time oe.elf.machine_dict() is called a large dictionary is created
and returned. However, the "arch" package_qa test will call this method
for every binary in a package, which results in a lot of dictionary
creation.
Concrete exmaple: in running ltp:do_package_qa, the arch test takes 25%
of the runtime, and opitimising the machine_dict() call to cache the
generated dictionary reduces the runtime from 57s to 44s.
(From OE-Core rev: dca4455aa4f870bad900a0214c4e95e09a055295)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
| -rw-r--r-- | meta/lib/oe/elf.py | 264 |
1 files changed, 133 insertions, 131 deletions
diff --git a/meta/lib/oe/elf.py b/meta/lib/oe/elf.py index eab2349a4f..e1bc7b8984 100644 --- a/meta/lib/oe/elf.py +++ b/meta/lib/oe/elf.py | |||
| @@ -5,141 +5,143 @@ | |||
| 5 | # | 5 | # |
| 6 | 6 | ||
| 7 | def machine_dict(d): | 7 | def machine_dict(d): |
| 8 | # TARGET_OS TARGET_ARCH MACHINE, OSABI, ABIVERSION, Little Endian, 32bit? | 8 | # Generating this data is slow, so cache it |
| 9 | machdata = { | 9 | if not hasattr(machine_dict, "machdata"): |
| 10 | "darwin9" : { | 10 | machine_dict.machdata = { |
| 11 | "arm" : (40, 0, 0, True, 32), | 11 | # TARGET_OS TARGET_ARCH MACHINE, OSABI, ABIVERSION, Little Endian, 32bit? |
| 12 | }, | 12 | "darwin9" : { |
| 13 | "eabi" : { | 13 | "arm" : (40, 0, 0, True, 32), |
| 14 | "arm" : (40, 0, 0, True, 32), | 14 | }, |
| 15 | }, | 15 | "eabi" : { |
| 16 | "elf" : { | 16 | "arm" : (40, 0, 0, True, 32), |
| 17 | "aarch64" : (183, 0, 0, True, 64), | 17 | }, |
| 18 | "aarch64_be" :(183, 0, 0, False, 64), | 18 | "elf" : { |
| 19 | "i586" : (3, 0, 0, True, 32), | 19 | "aarch64" : (183, 0, 0, True, 64), |
| 20 | "i686" : (3, 0, 0, True, 32), | 20 | "aarch64_be" :(183, 0, 0, False, 64), |
| 21 | "x86_64": (62, 0, 0, True, 64), | 21 | "i586" : (3, 0, 0, True, 32), |
| 22 | "epiphany": (4643, 0, 0, True, 32), | 22 | "i686" : (3, 0, 0, True, 32), |
| 23 | "lm32": (138, 0, 0, False, 32), | 23 | "x86_64": (62, 0, 0, True, 64), |
| 24 | "loongarch64":(258, 0, 0, True, 64), | 24 | "epiphany": (4643, 0, 0, True, 32), |
| 25 | "mips": ( 8, 0, 0, False, 32), | 25 | "lm32": (138, 0, 0, False, 32), |
| 26 | "mipsel": ( 8, 0, 0, True, 32), | 26 | "loongarch64":(258, 0, 0, True, 64), |
| 27 | "microblaze": (189, 0, 0, False, 32), | 27 | "mips": ( 8, 0, 0, False, 32), |
| 28 | "microblazeel":(189, 0, 0, True, 32), | 28 | "mipsel": ( 8, 0, 0, True, 32), |
| 29 | "powerpc": (20, 0, 0, False, 32), | 29 | "microblaze": (189, 0, 0, False, 32), |
| 30 | "riscv32": (243, 0, 0, True, 32), | 30 | "microblazeel":(189, 0, 0, True, 32), |
| 31 | "riscv64": (243, 0, 0, True, 64), | 31 | "powerpc": (20, 0, 0, False, 32), |
| 32 | }, | 32 | "riscv32": (243, 0, 0, True, 32), |
| 33 | "linux" : { | 33 | "riscv64": (243, 0, 0, True, 64), |
| 34 | "aarch64" : (183, 0, 0, True, 64), | 34 | }, |
| 35 | "aarch64_be" :(183, 0, 0, False, 64), | 35 | "linux" : { |
| 36 | "arm" : (40, 97, 0, True, 32), | 36 | "aarch64" : (183, 0, 0, True, 64), |
| 37 | "armeb": (40, 97, 0, False, 32), | 37 | "aarch64_be" :(183, 0, 0, False, 64), |
| 38 | "powerpc": (20, 0, 0, False, 32), | 38 | "arm" : (40, 97, 0, True, 32), |
| 39 | "powerpc64": (21, 0, 0, False, 64), | 39 | "armeb": (40, 97, 0, False, 32), |
| 40 | "powerpc64le": (21, 0, 0, True, 64), | 40 | "powerpc": (20, 0, 0, False, 32), |
| 41 | "i386": ( 3, 0, 0, True, 32), | 41 | "powerpc64": (21, 0, 0, False, 64), |
| 42 | "i486": ( 3, 0, 0, True, 32), | 42 | "powerpc64le": (21, 0, 0, True, 64), |
| 43 | "i586": ( 3, 0, 0, True, 32), | 43 | "i386": ( 3, 0, 0, True, 32), |
| 44 | "i686": ( 3, 0, 0, True, 32), | 44 | "i486": ( 3, 0, 0, True, 32), |
| 45 | "x86_64": (62, 0, 0, True, 64), | 45 | "i586": ( 3, 0, 0, True, 32), |
| 46 | "ia64": (50, 0, 0, True, 64), | 46 | "i686": ( 3, 0, 0, True, 32), |
| 47 | "alpha": (36902, 0, 0, True, 64), | 47 | "x86_64": (62, 0, 0, True, 64), |
| 48 | "hppa": (15, 3, 0, False, 32), | 48 | "ia64": (50, 0, 0, True, 64), |
| 49 | "loongarch64":(258, 0, 0, True, 64), | 49 | "alpha": (36902, 0, 0, True, 64), |
| 50 | "m68k": ( 4, 0, 0, False, 32), | 50 | "hppa": (15, 3, 0, False, 32), |
| 51 | "mips": ( 8, 0, 0, False, 32), | 51 | "loongarch64":(258, 0, 0, True, 64), |
| 52 | "mipsel": ( 8, 0, 0, True, 32), | 52 | "m68k": ( 4, 0, 0, False, 32), |
| 53 | "mips64": ( 8, 0, 0, False, 64), | 53 | "mips": ( 8, 0, 0, False, 32), |
| 54 | "mips64el": ( 8, 0, 0, True, 64), | 54 | "mipsel": ( 8, 0, 0, True, 32), |
| 55 | "mipsisa32r6": ( 8, 0, 0, False, 32), | 55 | "mips64": ( 8, 0, 0, False, 64), |
| 56 | "mipsisa32r6el": ( 8, 0, 0, True, 32), | 56 | "mips64el": ( 8, 0, 0, True, 64), |
| 57 | "mipsisa64r6": ( 8, 0, 0, False, 64), | 57 | "mipsisa32r6": ( 8, 0, 0, False, 32), |
| 58 | "mipsisa64r6el": ( 8, 0, 0, True, 64), | 58 | "mipsisa32r6el": ( 8, 0, 0, True, 32), |
| 59 | "nios2": (113, 0, 0, True, 32), | 59 | "mipsisa64r6": ( 8, 0, 0, False, 64), |
| 60 | "riscv32": (243, 0, 0, True, 32), | 60 | "mipsisa64r6el": ( 8, 0, 0, True, 64), |
| 61 | "riscv64": (243, 0, 0, True, 64), | 61 | "nios2": (113, 0, 0, True, 32), |
| 62 | "s390": (22, 0, 0, False, 32), | 62 | "riscv32": (243, 0, 0, True, 32), |
| 63 | "sh4": (42, 0, 0, True, 32), | 63 | "riscv64": (243, 0, 0, True, 64), |
| 64 | "sparc": ( 2, 0, 0, False, 32), | 64 | "s390": (22, 0, 0, False, 32), |
| 65 | "microblaze": (189, 0, 0, False, 32), | 65 | "sh4": (42, 0, 0, True, 32), |
| 66 | "microblazeel":(189, 0, 0, True, 32), | 66 | "sparc": ( 2, 0, 0, False, 32), |
| 67 | }, | 67 | "microblaze": (189, 0, 0, False, 32), |
| 68 | "linux-android" : { | 68 | "microblazeel":(189, 0, 0, True, 32), |
| 69 | "aarch64" : (183, 0, 0, True, 64), | 69 | }, |
| 70 | "i686": ( 3, 0, 0, True, 32), | 70 | "linux-android" : { |
| 71 | "x86_64": (62, 0, 0, True, 64), | 71 | "aarch64" : (183, 0, 0, True, 64), |
| 72 | }, | 72 | "i686": ( 3, 0, 0, True, 32), |
| 73 | "linux-androideabi" : { | 73 | "x86_64": (62, 0, 0, True, 64), |
| 74 | "arm" : (40, 97, 0, True, 32), | 74 | }, |
| 75 | }, | 75 | "linux-androideabi" : { |
| 76 | "linux-musl" : { | 76 | "arm" : (40, 97, 0, True, 32), |
| 77 | "aarch64" : (183, 0, 0, True, 64), | 77 | }, |
| 78 | "aarch64_be" :(183, 0, 0, False, 64), | 78 | "linux-musl" : { |
| 79 | "arm" : ( 40, 97, 0, True, 32), | 79 | "aarch64" : (183, 0, 0, True, 64), |
| 80 | "armeb": ( 40, 97, 0, False, 32), | 80 | "aarch64_be" :(183, 0, 0, False, 64), |
| 81 | "powerpc": ( 20, 0, 0, False, 32), | 81 | "arm" : ( 40, 97, 0, True, 32), |
| 82 | "powerpc64": ( 21, 0, 0, False, 64), | 82 | "armeb": ( 40, 97, 0, False, 32), |
| 83 | "powerpc64le": (21, 0, 0, True, 64), | 83 | "powerpc": ( 20, 0, 0, False, 32), |
| 84 | "i386": ( 3, 0, 0, True, 32), | 84 | "powerpc64": ( 21, 0, 0, False, 64), |
| 85 | "i486": ( 3, 0, 0, True, 32), | 85 | "powerpc64le": (21, 0, 0, True, 64), |
| 86 | "i586": ( 3, 0, 0, True, 32), | 86 | "i386": ( 3, 0, 0, True, 32), |
| 87 | "i686": ( 3, 0, 0, True, 32), | 87 | "i486": ( 3, 0, 0, True, 32), |
| 88 | "x86_64": ( 62, 0, 0, True, 64), | 88 | "i586": ( 3, 0, 0, True, 32), |
| 89 | "mips": ( 8, 0, 0, False, 32), | 89 | "i686": ( 3, 0, 0, True, 32), |
| 90 | "mipsel": ( 8, 0, 0, True, 32), | 90 | "x86_64": ( 62, 0, 0, True, 64), |
| 91 | "mips64": ( 8, 0, 0, False, 64), | 91 | "mips": ( 8, 0, 0, False, 32), |
| 92 | "mips64el": ( 8, 0, 0, True, 64), | 92 | "mipsel": ( 8, 0, 0, True, 32), |
| 93 | "microblaze": (189, 0, 0, False, 32), | 93 | "mips64": ( 8, 0, 0, False, 64), |
| 94 | "microblazeel":(189, 0, 0, True, 32), | 94 | "mips64el": ( 8, 0, 0, True, 64), |
| 95 | "riscv32": (243, 0, 0, True, 32), | 95 | "microblaze": (189, 0, 0, False, 32), |
| 96 | "riscv64": (243, 0, 0, True, 64), | 96 | "microblazeel":(189, 0, 0, True, 32), |
| 97 | "sh4": ( 42, 0, 0, True, 32), | 97 | "riscv32": (243, 0, 0, True, 32), |
| 98 | }, | 98 | "riscv64": (243, 0, 0, True, 64), |
| 99 | "uclinux-uclibc" : { | 99 | "sh4": ( 42, 0, 0, True, 32), |
| 100 | "bfin": ( 106, 0, 0, True, 32), | 100 | }, |
| 101 | }, | 101 | "uclinux-uclibc" : { |
| 102 | "linux-gnueabi" : { | 102 | "bfin": ( 106, 0, 0, True, 32), |
| 103 | "arm" : (40, 0, 0, True, 32), | 103 | }, |
| 104 | "armeb" : (40, 0, 0, False, 32), | 104 | "linux-gnueabi" : { |
| 105 | }, | 105 | "arm" : (40, 0, 0, True, 32), |
| 106 | "linux-musleabi" : { | 106 | "armeb" : (40, 0, 0, False, 32), |
| 107 | "arm" : (40, 0, 0, True, 32), | 107 | }, |
| 108 | "armeb" : (40, 0, 0, False, 32), | 108 | "linux-musleabi" : { |
| 109 | }, | 109 | "arm" : (40, 0, 0, True, 32), |
| 110 | "linux-gnuspe" : { | 110 | "armeb" : (40, 0, 0, False, 32), |
| 111 | "powerpc": (20, 0, 0, False, 32), | 111 | }, |
| 112 | }, | 112 | "linux-gnuspe" : { |
| 113 | "linux-muslspe" : { | 113 | "powerpc": (20, 0, 0, False, 32), |
| 114 | "powerpc": (20, 0, 0, False, 32), | 114 | }, |
| 115 | }, | 115 | "linux-muslspe" : { |
| 116 | "linux-gnu" : { | 116 | "powerpc": (20, 0, 0, False, 32), |
| 117 | "powerpc": (20, 0, 0, False, 32), | 117 | }, |
| 118 | "sh4": (42, 0, 0, True, 32), | 118 | "linux-gnu" : { |
| 119 | }, | 119 | "powerpc": (20, 0, 0, False, 32), |
| 120 | "linux-gnu_ilp32" : { | 120 | "sh4": (42, 0, 0, True, 32), |
| 121 | "aarch64" : (183, 0, 0, True, 32), | 121 | }, |
| 122 | }, | 122 | "linux-gnu_ilp32" : { |
| 123 | "linux-gnux32" : { | 123 | "aarch64" : (183, 0, 0, True, 32), |
| 124 | "x86_64": (62, 0, 0, True, 32), | 124 | }, |
| 125 | }, | 125 | "linux-gnux32" : { |
| 126 | "linux-muslx32" : { | 126 | "x86_64": (62, 0, 0, True, 32), |
| 127 | "x86_64": (62, 0, 0, True, 32), | 127 | }, |
| 128 | }, | 128 | "linux-muslx32" : { |
| 129 | "linux-gnun32" : { | 129 | "x86_64": (62, 0, 0, True, 32), |
| 130 | "mips64": ( 8, 0, 0, False, 32), | 130 | }, |
| 131 | "mips64el": ( 8, 0, 0, True, 32), | 131 | "linux-gnun32" : { |
| 132 | "mipsisa64r6": ( 8, 0, 0, False, 32), | 132 | "mips64": ( 8, 0, 0, False, 32), |
| 133 | "mipsisa64r6el":( 8, 0, 0, True, 32), | 133 | "mips64el": ( 8, 0, 0, True, 32), |
| 134 | }, | 134 | "mipsisa64r6": ( 8, 0, 0, False, 32), |
| 135 | } | 135 | "mipsisa64r6el":( 8, 0, 0, True, 32), |
| 136 | }, | ||
| 137 | } | ||
| 136 | 138 | ||
| 137 | # Add in any extra user supplied data which may come from a BSP layer, removing the | 139 | # Add in any extra user supplied data which may come from a BSP layer, removing the |
| 138 | # need to always change this class directly | 140 | # need to always change this class directly |
| 139 | extra_machdata = (d and d.getVar("PACKAGEQA_EXTRA_MACHDEFFUNCS" or None) or "").split() | 141 | extra_machdata = (d and d.getVar("PACKAGEQA_EXTRA_MACHDEFFUNCS" or None) or "").split() |
| 140 | for m in extra_machdata: | 142 | for m in extra_machdata: |
| 141 | call = m + "(machdata, d)" | 143 | call = m + "(machdata, d)" |
| 142 | locs = { "machdata" : machdata, "d" : d} | 144 | locs = { "machdata" : machine_dict.machdata, "d" : d} |
| 143 | machdata = bb.utils.better_eval(call, locs) | 145 | machine_dict.machdata = bb.utils.better_eval(call, locs) |
| 144 | 146 | ||
| 145 | return machdata | 147 | return machine_dict.machdata |
