Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't include "params.h" if building with GCC 10 #183

Merged
merged 1 commit into from
Sep 19, 2020
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-c-api/gcc-cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
#include "gimple-iterator.h"
#endif

/* gcc 10 removed this header */
#if (GCC_VERSION < 10000)
#include "params.h"
#endif

#include "tree.h"
#include "diagnostic.h"
#include "cgraph.h"
Expand Down
5 changes: 5 additions & 0 deletions gcc-c-api/gcc-function.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@

/* TODO: rationalize these headers */
#include "tree.h"

/* gcc 10 removed this header */
#if (GCC_VERSION < 10000)
#include "params.h"
#endif

#include "tree.h"
#include "function.h"
#include "diagnostic.h"
Expand Down
5 changes: 5 additions & 0 deletions gcc-c-api/gcc-gimple.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
#include "gimple.h"

#if 0

/* gcc 10 removed this header */
#if (GCC_VERSION < 10000)
#include "params.h"
#endif

#include "cp/name-lookup.h" /* for global_namespace */
#include "tree.h"
#include "diagnostic.h"
Expand Down
7 changes: 7 additions & 0 deletions gcc-python-option.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,14 @@ int PyGcc_option_is_enabled(enum opt_code opt_code)
{
/* Returns 1 if option OPT_IDX is enabled in OPTS, 0 if it is disabled,
or -1 if it isn't a simple on-off switch. */
#if (GCC_VERSION < 10000)
int i = option_enabled (opt_code, global_dc->option_state);
#else
/* Starting with GCC 10, options can be distinguished by language. */
/* TODO Expose the lang_mask to the user. */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a TODO? ;-)

int i = option_enabled (opt_code, CL_LANG_ALL, global_dc->option_state);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the CL_LANG_ALL right here?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that that param is used as a mask, so using CL_LANG_ALL here looks correct to me.

#endif

if (i == 1) {
return 1;
}
Expand Down
7 changes: 7 additions & 0 deletions gcc-python-parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
<http://www.gnu.org/licenses/>.
*/



#include <Python.h>
#include "gcc-python.h"
#include "gcc-python-wrappers.h"

/* gcc 10 removed params.h */
#if (GCC_VERSION < 10000)

/*
Wrapper for GCC's params.h.
We specifically wrap "compiler_param" (a typedef to an enum)
Expand Down Expand Up @@ -50,6 +55,8 @@ PyGcc_WrtpMarkForPyGccParameter(PyGccParameter *wrapper)
/* empty */
}

#endif

/*
PEP-7
Local variables:
Expand Down
10 changes: 10 additions & 0 deletions gcc-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ PyGcc_get_option_dict(PyObject *self, PyObject *args)
return dict;
}

/* Function has been removed from GCC 10. */
#if (GCC_VERSION < 10000)
static PyObject *
PyGcc_get_parameters(PyObject *self, PyObject *args)
{
Expand Down Expand Up @@ -256,6 +258,7 @@ PyGcc_get_parameters(PyObject *self, PyObject *args)
Py_XDECREF(dict);
return NULL;
}
#endif

IMPL_APPENDER(add_var_to_list,
gcc_variable,
Expand Down Expand Up @@ -452,9 +455,12 @@ static PyMethodDef GccMethods[] = {
("Get all command-line options, as a dict from command-line text strings "
"to gcc.Option instances")},

/* Function has been removed from GCC 10. */
#if (GCC_VERSION < 10000)
{"get_parameters", PyGcc_get_parameters, METH_NOARGS,
"Get all tunable GCC parameters. Returns a dictionary, mapping from"
"option name -> gcc.Parameter instance"},
#endif

{"get_variables", PyGcc_get_variables, METH_NOARGS,
"Get all variables in this compilation unit as a list of gcc.Variable"},
Expand Down Expand Up @@ -811,7 +817,9 @@ plugin_init (struct plugin_name_args *plugin_info,
autogenerated_gimple_init_types(); /* FIXME: error checking! */
autogenerated_location_init_types(); /* FIXME: error checking! */
autogenerated_option_init_types(); /* FIXME: error checking! */
#if (GCC_VERSION < 10000)
autogenerated_parameter_init_types(); /* FIXME: error checking! */
#endif
autogenerated_pass_init_types(); /* FIXME: error checking! */
autogenerated_pretty_printer_init_types(); /* FIXME: error checking! */
autogenerated_rtl_init_types(); /* FIXME: error checking! */
Expand All @@ -826,7 +834,9 @@ plugin_init (struct plugin_name_args *plugin_info,
autogenerated_gimple_add_types(PyGcc_globals.module);
autogenerated_location_add_types(PyGcc_globals.module);
autogenerated_option_add_types(PyGcc_globals.module);
#if (GCC_VERSION < 10000)
autogenerated_parameter_add_types(PyGcc_globals.module);
#endif
autogenerated_pass_add_types(PyGcc_globals.module);
autogenerated_pretty_printer_add_types(PyGcc_globals.module);
autogenerated_rtl_add_types(PyGcc_globals.module);
Expand Down
11 changes: 11 additions & 0 deletions gcc-python.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
#endif
#include "gimple.h"


/* gcc 10 removed this header */
#if (GCC_VERSION < 10000)
#include "params.h"
#endif

#endif
#include "gcc-c-api/gcc-cfg.h"

Expand Down Expand Up @@ -226,10 +231,13 @@ DECLARE_SIMPLE_WRAPPER(PyGccOption,
option,
gcc_option, opt)

/* gcc 10 removed params.h */
#if (GCC_VERSION < 10000)
DECLARE_SIMPLE_WRAPPER(PyGccParameter,
PyGccParameter_TypeObj,
param_num,
compiler_param, param_num)
#endif

DECLARE_SIMPLE_WRAPPER(PyGccRtl,
PyGccRtl_TypeObj,
Expand Down Expand Up @@ -276,9 +284,12 @@ void autogenerated_location_add_types(PyObject *m);
int autogenerated_option_init_types(void);
void autogenerated_option_add_types(PyObject *m);

/* GCC 10 removed params.h */
#if (GCC_VERSION < 10000)
/* autogenerated-parameter.c */
int autogenerated_parameter_init_types(void);
void autogenerated_parameter_add_types(PyObject *m);
#endif

/* autogenerated-pass.c */
int autogenerated_pass_init_types(void);
Expand Down
11 changes: 11 additions & 0 deletions generate-parameter-c.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@

from cpybuilder import *
from wrapperbuilder import PyGccWrapperTypeObject
import os, subprocess, sys

if not os.path.exists("./print-gcc-version"):
sys.stderr.write("Build make target 'print-gcc-version' before running this script.")
sys.exit(1)

gcc_version = int(subprocess.check_output("./print-gcc-version"))

if gcc_version >= 10000:
print("/* GCC10 has removed params.h; no need for this wrapper. */")
sys.exit(0)

cu = CompilationUnit()
cu.add_include('gcc-python.h')
Expand Down