Skip to content

Commit c320ee1

Browse files
authored
Do not call host_detect_local_cpu when cross-compiling (#79)
* Do not call host_detect_local_cpu when cross-compiling * Update 128-bit patch
1 parent 4a8c8ec commit c320ee1

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

gcc/config/aarch64/aarch64-jit.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ along with GCC; see the file COPYING3. If not see
2929

3030
/* Implement TARGET_JIT_REGISTER_CPU_TARGET_INFO. */
3131

32+
#ifndef CROSS_DIRECTORY_STRUCTURE
3233
extern const char *host_detect_local_cpu (int argc, const char **argv);
34+
#endif
3335

3436
void
3537
aarch64_jit_register_target_info (void)
@@ -39,6 +41,7 @@ aarch64_jit_register_target_info (void)
3941
(val & ((1ULL << number) - 1ULL) << start) >> start
4042

4143
const char *params[] = {"arch"};
44+
#ifndef CROSS_DIRECTORY_STRUCTURE
4245
const char* local_cpu = host_detect_local_cpu (2, params);
4346
if (local_cpu != NULL)
4447
{
@@ -52,6 +55,7 @@ aarch64_jit_register_target_info (void)
5255
std::string cpu = arch.substr (arg_pos, end_pos - arg_pos);
5356
jit_target_set_arch (cpu);
5457
}
58+
#endif
5559

5660
if (targetm.scalar_mode_supported_p (TImode))
5761
{

gcc/config/i386/i386-jit.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ along with GCC; see the file COPYING3. If not see
2929

3030
/* Implement TARGET_JIT_REGISTER_CPU_TARGET_INFO. */
3131

32+
#ifndef CROSS_DIRECTORY_STRUCTURE
3233
extern const char *host_detect_local_cpu (int argc, const char **argv);
34+
#endif
3335

3436
#if TARGET_64BIT_DEFAULT
3537
const char* x86_bits = "64";
@@ -40,17 +42,22 @@ const char* x86_bits = "32";
4042
void
4143
ix86_jit_register_target_info (void)
4244
{
45+
#ifndef CROSS_DIRECTORY_STRUCTURE
4346
const char *params[] = {"arch", x86_bits};
4447
const char* local_cpu = host_detect_local_cpu (2, params);
45-
std::string arch = local_cpu;
46-
free (const_cast <char *> (local_cpu));
48+
if (local_cpu != NULL)
49+
{
50+
std::string arch = local_cpu;
51+
free (const_cast <char *> (local_cpu));
4752

48-
const char* arg = "-march=";
49-
size_t arg_pos = arch.find (arg) + strlen (arg);
50-
size_t end_pos = arch.find (" ", arg_pos);
53+
const char* arg = "-march=";
54+
size_t arg_pos = arch.find (arg) + strlen (arg);
55+
size_t end_pos = arch.find (" ", arg_pos);
5156

52-
std::string cpu = arch.substr (arg_pos, end_pos - arg_pos);
53-
jit_target_set_arch (cpu);
57+
std::string cpu = arch.substr (arg_pos, end_pos - arg_pos);
58+
jit_target_set_arch (cpu);
59+
}
60+
#endif
5461

5562
if (targetm.scalar_mode_supported_p (TImode))
5663
{

patches/0001-Disable-128-bit-integers-for-testing-purposes.patch

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From d4a4d284c76822280c5f4c05ae4a4d4a58bbeda9 Mon Sep 17 00:00:00 2001
1+
From 7e874be65179f729c144329a8883fa162a29a123 Mon Sep 17 00:00:00 2001
22
From: Antoni Boucher <[email protected]>
3-
Date: Fri, 16 Feb 2024 12:04:40 -0500
3+
Date: Fri, 19 Sep 2025 10:38:46 -0400
44
Subject: [PATCH] Disable 128-bit integers for testing purposes
55

66
---
@@ -10,12 +10,12 @@ Subject: [PATCH] Disable 128-bit integers for testing purposes
1010
3 files changed, 8 insertions(+), 8 deletions(-)
1111

1212
diff --git a/gcc/config/aarch64/aarch64-jit.cc b/gcc/config/aarch64/aarch64-jit.cc
13-
index b1cb446baa4..0499e0b0ab1 100644
13+
index df14b577867..bdc1708dd05 100644
1414
--- a/gcc/config/aarch64/aarch64-jit.cc
1515
+++ b/gcc/config/aarch64/aarch64-jit.cc
16-
@@ -53,11 +53,11 @@ aarch64_jit_register_target_info (void)
17-
jit_target_set_arch (cpu);
16+
@@ -57,11 +57,11 @@ aarch64_jit_register_target_info (void)
1817
}
18+
#endif
1919

2020
- if (targetm.scalar_mode_supported_p (TImode))
2121
+ /*if (targetm.scalar_mode_supported_p (TImode))
@@ -28,12 +28,12 @@ index b1cb446baa4..0499e0b0ab1 100644
2828
if (float16_type_node != NULL && TYPE_PRECISION(float16_type_node) == 16)
2929
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT16);
3030
diff --git a/gcc/config/i386/i386-jit.cc b/gcc/config/i386/i386-jit.cc
31-
index 8e085ff4526..f839201c084 100644
31+
index 7f9f561911e..0e926de5258 100644
3232
--- a/gcc/config/i386/i386-jit.cc
3333
+++ b/gcc/config/i386/i386-jit.cc
34-
@@ -52,11 +52,11 @@ ix86_jit_register_target_info (void)
35-
std::string cpu = arch.substr (arg_pos, end_pos - arg_pos);
36-
jit_target_set_arch (cpu);
34+
@@ -59,11 +59,11 @@ ix86_jit_register_target_info (void)
35+
}
36+
#endif
3737

3838
- if (targetm.scalar_mode_supported_p (TImode))
3939
+ /*if (targetm.scalar_mode_supported_p (TImode))
@@ -46,7 +46,7 @@ index 8e085ff4526..f839201c084 100644
4646
if (float16_type_node != NULL && TYPE_PRECISION(float16_type_node) == 16)
4747
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT16);
4848
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
49-
index 6badbaf0d6f..97160e08103 100644
49+
index 4da3156af74..2593288c5ee 100644
5050
--- a/gcc/jit/jit-playback.cc
5151
+++ b/gcc/jit/jit-playback.cc
5252
@@ -250,8 +250,8 @@ get_tree_node_for_type (enum gcc_jit_types type_)
@@ -72,5 +72,5 @@ index 6badbaf0d6f..97160e08103 100644
7272
add_error (NULL, "gcc_jit_types value unsupported on this target: %i",
7373
type_);
7474
--
75-
2.50.0
75+
2.51.0
7676

0 commit comments

Comments
 (0)