Skip to content

Commit 28b84db

Browse files
committed
libgccjit: Add a function to check if LTO is supported
1 parent 901bb88 commit 28b84db

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

gcc/jit/Make-lang.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ jit.serial = $(LIBGCCJIT_FILENAME)
130130
# Tell GNU make to ignore these if they exist.
131131
.PHONY: jit
132132

133+
CFLAGS-jit/libgccjit.o += -DDEFAULT_TARGET_VERSION=\"$(version)\" \
134+
-DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\" \
135+
-DSTANDARD_LIBEXEC_PREFIX=\"$(libexecdir)/gcc/\"
136+
133137
JIT_OBJS = attribs.o \
134138
jit/dummy-frontend.o \
135139
jit/libgccjit.o \

gcc/jit/libgccjit.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4920,3 +4920,18 @@ gcc_jit_function_set_location (gcc_jit_function *func,
49204920

49214921
func->set_loc (loc);
49224922
}
4923+
4924+
bool
4925+
gcc_jit_is_lto_supported ()
4926+
{
4927+
#ifdef ENABLE_LTO
4928+
char lto1_path[PATH_MAX];
4929+
snprintf (lto1_path, sizeof(lto1_path), "%s%s/%s/lto1",
4930+
STANDARD_LIBEXEC_PREFIX, DEFAULT_TARGET_MACHINE, DEFAULT_TARGET_VERSION);
4931+
if (access (lto1_path, X_OK) == 0) {
4932+
return true;
4933+
}
4934+
#endif
4935+
4936+
return false;
4937+
}

gcc/jit/libgccjit.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,9 @@ extern void
23322332
gcc_jit_rvalue_set_location (gcc_jit_rvalue *rvalue,
23332333
gcc_jit_location *loc);
23342334

2335+
extern bool
2336+
gcc_jit_is_lto_supported ();
2337+
23352338
#ifdef __cplusplus
23362339
}
23372340
#endif /* __cplusplus */

gcc/jit/libgccjit.map

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,8 @@ LIBGCCJIT_ABI_45{
388388
global:
389389
gcc_jit_lvalue_set_name;
390390
} LIBGCCJIT_ABI_44;
391+
392+
LIBGCCJIT_ABI_46 {
393+
global:
394+
gcc_jit_is_lto_supported;
395+
} LIBGCCJIT_ABI_45;

0 commit comments

Comments
 (0)