Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gcc/jit/dummy-frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ static const scoped_attribute_specs *const jit_attribute_table[] =
};

char* jit_personality_func_name = NULL;
const char* jit_lang_name = NULL;
static tree personality_decl;

/* FIXME: This is a hack to preserve trees that we create from the
Expand Down Expand Up @@ -1086,6 +1087,9 @@ jit_end_diagnostic (diagnostics::text_sink &,
static bool
jit_langhook_init (void)
{
if (jit_lang_name)
lang_hooks.name = jit_lang_name;

jit_gc_root = NULL_TREE;
personality_decl = NULL_TREE;
gcc_assert (gcc::jit::active_playback_ctxt);
Expand Down
9 changes: 9 additions & 0 deletions gcc/jit/jit-playback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3319,6 +3319,11 @@ make_fake_args (vec <char *> *argvec,
ADD_ARG (get_path_c_file ());
ADD_ARG ("-fPIC");

// Explicitly set the .s file path since the user can customize the path of
// the fake C file via gcc_jit_context_set_filename.
ADD_ARG ("-o");
ADD_ARG (get_path_s_file ());

/* Handle int options: */
switch (get_int_option (GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL))
{
Expand Down Expand Up @@ -3886,6 +3891,10 @@ const char *
playback::context::
get_path_c_file () const
{
const char *filename = m_recording_ctxt->get_filename ();
if (filename)
return filename;

return m_tempdir->get_path_c_file ();
}

Expand Down
15 changes: 15 additions & 0 deletions gcc/jit/jit-recording.cc
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,9 @@ recording::context::~context ()
if (m_owns_last_error_str)
if (m_last_error_str != m_first_error_str)
free (m_last_error_str);

if (m_filename)
free (m_filename);
}

/* Add the given mememto to the list of those tracked by this
Expand Down Expand Up @@ -1495,6 +1498,18 @@ recording::context::new_case (recording::rvalue *min_value,
return result;
}

const char *
recording::context::get_filename ()
{
return m_filename;
}

void
recording::context::set_filename (const char *filename)
{
m_filename = xstrdup(filename);
}

/* Set the given string option for this context, or add an error if
it's not recognized.

Expand Down
8 changes: 8 additions & 0 deletions gcc/jit/jit-recording.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ class context : public log_user
rvalue *max_value,
block *block);

const char *
get_filename ();

void
set_filename (const char *filename);

void
set_str_option (enum gcc_jit_str_option opt,
const char *value);
Expand Down Expand Up @@ -437,6 +443,8 @@ class context : public log_user
builtins_manager *m_builtins_manager; // lazily created

target_info *m_target_info;

char *m_filename = nullptr;
};


Expand Down
18 changes: 18 additions & 0 deletions gcc/jit/libgccjit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4016,6 +4016,16 @@ gcc_jit_context_set_output_ident (gcc_jit_context *ctxt,
ctxt->set_output_ident (output_ident);
}

void
gcc_jit_context_set_filename (gcc_jit_context *ctxt, const char *filename)
{
RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context");
RETURN_IF_FAIL (filename, ctxt, NULL, "NULL filename");
JIT_LOG_FUNC (ctxt->get_logger ());

ctxt->set_filename (filename);
}

gcc_jit_target_info *
gcc_jit_context_get_target_info (gcc_jit_context *ctxt)
{
Expand Down Expand Up @@ -4935,3 +4945,11 @@ gcc_jit_is_lto_supported ()

return false;
}

extern const char* jit_lang_name;

void
gcc_jit_set_lang_name (const char *lang_name)
{
jit_lang_name = lang_name;
}
6 changes: 6 additions & 0 deletions gcc/jit/libgccjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,9 @@ gcc_jit_context_set_output_ident (gcc_jit_context *ctxt,

#define LIBGCCJIT_HAVE_gcc_jit_context_set_output_ident

extern void
gcc_jit_context_set_filename (gcc_jit_context *ctxt, const char *filename);

/* Add an attribute to a variable. */
extern void
gcc_jit_lvalue_add_attribute (gcc_jit_lvalue *variable,
Expand Down Expand Up @@ -2335,6 +2338,9 @@ gcc_jit_rvalue_set_location (gcc_jit_rvalue *rvalue,
extern bool
gcc_jit_is_lto_supported ();

extern void
gcc_jit_set_lang_name (const char *lang_name);

#ifdef __cplusplus
}
#endif /* __cplusplus */
Expand Down
6 changes: 6 additions & 0 deletions gcc/jit/libgccjit.map
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,9 @@ LIBGCCJIT_ABI_46 {
global:
gcc_jit_is_lto_supported;
} LIBGCCJIT_ABI_45;

LIBGCCJIT_ABI_47 {
global:
gcc_jit_set_lang_name;
gcc_jit_context_set_filename;
} LIBGCCJIT_ABI_46;