[gcc-python-plugin: 7/16] demo: reuse Python CFLAGS variable
by David Hugh Malcolm
commit df0fe2c24d1b3b51bd74431097fb9cfea5b362ce
Author: Kevin Pyle <gcc-python-plugin.8eaf7cd8e5128d8191fe(a)spamgourmet.com>
Date: Sun Mar 18 16:21:29 2012 -0500
demo: reuse Python CFLAGS variable
Convert demo recipe to use existing $(PYTHON_CFLAGS) instead of calling
python-config again.
Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/Makefile b/Makefile
index bfe60b3..eb82bb2 100644
--- a/Makefile
+++ b/Makefile
@@ -157,7 +157,7 @@ debug: plugin
# A simple demo, to make it easy to demonstrate the cpychecker:
demo: plugin
- ./gcc-with-cpychecker $(shell $(PYTHON_CONFIG) --cflags) demo.c
+ ./gcc-with-cpychecker $(PYTHON_CFLAGS) demo.c
json-examples: plugin
./gcc-with-cpychecker -I/usr/include/python2.7 libcpychecker/html/test/example1/bug.c
12 years, 2 months
[gcc-python-plugin: 6/16] Use $(RM), not explicit "rm -f".
by David Hugh Malcolm
commit 3f76a93818b47ca237c21a6d697df1e2e7c6d792
Author: Kevin Pyle <gcc-python-plugin.8eaf7cd8e5128d8191fe(a)spamgourmet.com>
Date: Sun Mar 18 16:21:29 2012 -0500
Use $(RM), not explicit "rm -f".
GNU make defines $RM as "rm -f", but using the indirect form allows the
user to override it if needed.
Makefile | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/Makefile b/Makefile
index 65308d1..bfe60b3 100644
--- a/Makefile
+++ b/Makefile
@@ -112,9 +112,8 @@ python.so: $(PLUGIN_OBJECT_FILES)
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared $^ -o $@
clean:
- rm -f *.so *.o
- rm -f autogenerated*
- rm -rf docs/_build
+ $(RM) *.so *.o autogenerated*
+ $(RM) -r docs/_build
autogenerated-config.h: configbuilder.py generate-config-h.py
$(PYTHON) generate-config-h.py -o $@ --gcc=$(CC)
12 years, 2 months
[gcc-python-plugin: 5/16] Split CPPFLAGS/CFLAGS/LDFLAGS.
by David Hugh Malcolm
commit c0c5a85c6ad3b73c989bf375e9321629c7c9f404
Author: Kevin Pyle <gcc-python-plugin.8eaf7cd8e5128d8191fe(a)spamgourmet.com>
Date: Sun Mar 18 16:21:28 2012 -0500
Split CPPFLAGS/CFLAGS/LDFLAGS.
Users may want to set other optimization or debug levels, so split
CFLAGS handling into two parts. The first part, which will be
overridden by user environment variables, sets the default optimization
and debug level for the project. The second part then applies values
that should always be used.
Also, move CPPFLAGS and LDFLAGS to their respective variables.
Makefile | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/Makefile b/Makefile
index 3425c5f..65308d1 100644
--- a/Makefile
+++ b/Makefile
@@ -93,9 +93,15 @@ PYTHON_CONFIG=python-config
PYTHON_CFLAGS=$(shell $(PYTHON_CONFIG) --cflags)
PYTHON_LDFLAGS=$(shell $(PYTHON_CONFIG) --ldflags)
-CFLAGS+= -I$(GCCPLUGINS_DIR)/include -fPIC -fno-strict-aliasing -O2 -Wall -Werror -g $(PYTHON_CFLAGS) $(PYTHON_LDFLAGS)
+CPPFLAGS+= -I$(GCCPLUGINS_DIR)/include
+# Allow user to pick optimization, choose whether warnings are fatal,
+# and choose debugging information level.
+CFLAGS?=-O2 -Werror -g
+# Force these settings
+CFLAGS+= -fPIC -fno-strict-aliasing -Wall $(PYTHON_CFLAGS)
+LDFLAGS+= $(PYTHON_LDFLAGS)
ifneq "$(PLUGIN_PYTHONPATH)" ""
- CFLAGS+= -DPLUGIN_PYTHONPATH='"$(PLUGIN_PYTHONPATH)"'
+ CPPFLAGS+= -DPLUGIN_PYTHONPATH='"$(PLUGIN_PYTHONPATH)"'
endif
all: autogenerated-config.h testcpybuilder test-suite testcpychecker
@@ -103,7 +109,7 @@ all: autogenerated-config.h testcpybuilder test-suite testcpychecker
plugin: autogenerated-config.h python.so
python.so: $(PLUGIN_OBJECT_FILES)
- $(CC) $(CFLAGS) -shared $^ -o $@
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared $^ -o $@
clean:
rm -f *.so *.o
12 years, 2 months
[gcc-python-plugin: 4/16] Use pattern rules for building generated files.
by David Hugh Malcolm
commit 4c083ca0670865fa4370af0fdf52d9dbeaed4e3b
Author: Kevin Pyle <gcc-python-plugin.8eaf7cd8e5128d8191fe(a)spamgourmet.com>
Date: Sun Mar 18 16:21:28 2012 -0500
Use pattern rules for building generated files.
Most of the generated files follow one of a small number of general
recipes. Replace the explicit per-file recipes with a pattern rule.
Makefile | 50 ++++++++------------------------------------------
1 files changed, 8 insertions(+), 42 deletions(-)
---
diff --git a/Makefile b/Makefile
index 9d3a226..3425c5f 100644
--- a/Makefile
+++ b/Makefile
@@ -113,50 +113,16 @@ clean:
autogenerated-config.h: configbuilder.py generate-config-h.py
$(PYTHON) generate-config-h.py -o $@ --gcc=$(CC)
-autogenerated-gimple-types.txt: gimple-types.txt.in
- cpp $(CFLAGS) $^ -o $@
+autogenerated-%.txt: %.txt.in
+ $(CPP) $(CPPFLAGS) -x c-header $^ -o $@
-autogenerated-rtl-types.txt: rtl-types.txt.in
- cpp $(CFLAGS) $^ -o $@
+autogenerated-%.c: generate-%-c.py $(GENERATOR_DEPS)
+ $(PYTHON) $< > $@
-autogenerated-tree-types.txt: tree-types.txt.in
- cpp $(CFLAGS) $^ -o $@
-
-autogenerated-callgraph.c: $(GENERATOR_DEPS) generate-callgraph-c.py
- $(PYTHON) generate-callgraph-c.py > $@
-
-autogenerated-cfg.c: $(GENERATOR_DEPS) generate-cfg-c.py
- $(PYTHON) generate-cfg-c.py > $@
-
-autogenerated-function.c: $(GENERATOR_DEPS) generate-function-c.py
- $(PYTHON) generate-function-c.py > $@
-
-autogenerated-gimple.c: $(GENERATOR_DEPS) generate-gimple-c.py autogenerated-gimple-types.txt maketreetypes.py
- $(PYTHON) generate-gimple-c.py > $@
-
-autogenerated-location.c: $(GENERATOR_DEPS) generate-location-c.py
- $(PYTHON) generate-location-c.py > $@
-
-autogenerated-option.c: $(GENERATOR_DEPS) generate-option-c.py
- $(PYTHON) generate-option-c.py > $@
-
-autogenerated-parameter.c: $(GENERATOR_DEPS) generate-parameter-c.py
- $(PYTHON) generate-parameter-c.py > $@
-
-autogenerated-pass.c: $(GENERATOR_DEPS) generate-pass-c.py
- $(PYTHON) generate-pass-c.py > $@
-
-autogenerated-pretty-printer.c: $(GENERATOR_DEPS) generate-pretty-printer-c.py
- $(PYTHON) generate-pretty-printer-c.py > $@
-
-autogenerated-tree.c: $(GENERATOR_DEPS) generate-tree-c.py autogenerated-tree-types.txt maketreetypes.py
- $(PYTHON) generate-tree-c.py > $@
-
-autogenerated-rtl.c: $(GENERATOR_DEPS) generate-rtl-c.py autogenerated-rtl-types.txt maketreetypes.py
- $(PYTHON) generate-rtl-c.py > $@
-
-autogenerated-variable.c: $(GENERATOR_DEPS) generate-variable-c.py autogenerated-gimple-types.txt maketreetypes.py
- $(PYTHON) generate-variable-c.py > $@
+autogenerated-gimple.c: autogenerated-gimple-types.txt maketreetypes.py
+autogenerated-tree.c: autogenerated-tree-types.txt maketreetypes.py
+autogenerated-rtl.c: autogenerated-rtl-types.txt maketreetypes.py
+autogenerated-variable.c: autogenerated-gimple-types.txt maketreetypes.py
# Hint for debugging: add -v to the gcc options
# to get a command line for invoking individual subprocesses
12 years, 2 months
[gcc-python-plugin: 3/16] Use $(CURDIR) instead of shell call.
by David Hugh Malcolm
commit 5bdf3521338a7183d77f05c58165095d50351138
Author: Kevin Pyle <gcc-python-plugin.8eaf7cd8e5128d8191fe(a)spamgourmet.com>
Date: Sun Mar 18 16:21:28 2012 -0500
Use $(CURDIR) instead of shell call.
GNU make sets CURDIR to the value of the current directory. Use that
instead of running a subshell to execute 'pwd'.
Makefile | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/Makefile b/Makefile
index 90bc716..9d3a226 100644
--- a/Makefile
+++ b/Makefile
@@ -163,12 +163,12 @@ autogenerated-variable.c: $(GENERATOR_DEPS) generate-variable-c.py autogenerated
# Doing so seems to require that paths be absolute, rather than relative
# to this directory
TEST_CFLAGS= \
- -fplugin=$(shell pwd)/python.so \
+ -fplugin=$(CURDIR)/python.so \
-fplugin-arg-python-script=test.py
# A catch-all test for quick experimentation with the API:
test: plugin
- $(CC) -v $(TEST_CFLAGS) $(shell pwd)/test.c
+ $(CC) -v $(TEST_CFLAGS) $(CURDIR)/test.c
# Selftest for the cpychecker.py code:
testcpychecker: plugin
@@ -179,10 +179,10 @@ testcpybuilder:
$(PYTHON) testcpybuilder.py -v
dump_gimple:
- $(CC) -fdump-tree-gimple $(shell pwd)/test.c
+ $(CC) -fdump-tree-gimple $(CURDIR)/test.c
debug: plugin
- $(CC) -v $(TEST_CFLAGS) $(shell pwd)/test.c
+ $(CC) -v $(TEST_CFLAGS) $(CURDIR)/test.c
# A simple demo, to make it easy to demonstrate the cpychecker:
demo: plugin
12 years, 2 months
[gcc-python-plugin: 2/16] Build: add various pseudo-targets to .PHONY
by David Hugh Malcolm
commit 3ea2de7efa17b1ab60b9aa9382aacf5b93925096
Author: Kevin Pyle <gcc-python-plugin.8eaf7cd8e5128d8191fe(a)spamgourmet.com>
Date: Sun Mar 18 16:21:28 2012 -0500
Build: add various pseudo-targets to .PHONY
Listing these targets in .PHONY forces make not to check for a
corresponding file. This is a slight performance improvement and avoids
unwanted behavior if the build directory ever has a file named 'all',
'clean', etc.
Makefile | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/Makefile b/Makefile
index dcba3a4..90bc716 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,8 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
+.PHONY: all clean debug dump_gimple plugin show-ssa tarball test-suite testcpychecker testcpybuilder
+
PLUGIN_SOURCE_FILES= \
gcc-python.c \
gcc-python-attribute.c \
12 years, 2 months
[gcc-python-plugin: 1/16] Derive gcc name from $CC, not $GCC
by David Hugh Malcolm
commit 82d6200d2f412cbc6636bf0661fea8cbee08e5a2
Author: Kevin Pyle <gcc-python-plugin.8eaf7cd8e5128d8191fe(a)spamgourmet.com>
Date: Sun Mar 18 16:21:28 2012 -0500
Derive gcc name from $CC, not $GCC
Make assumes that CC will be set to the active C compiler, so package
managers automatically set CC accordingly. Read $CC instead of $GCC to
take advantage of that.
Makefile | 14 ++++++--------
configbuilder.py | 2 +-
run-test-suite.py | 2 +-
test-builder.py | 4 ++--
testcpybuilder.py | 2 +-
5 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/Makefile b/Makefile
index 8efad81..dcba3a4 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,6 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
-GCC=gcc
-
PLUGIN_SOURCE_FILES= \
gcc-python.c \
gcc-python-attribute.c \
@@ -51,7 +49,7 @@ PLUGIN_SOURCE_FILES= \
autogenerated-variable.c
PLUGIN_OBJECT_FILES= $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
-GCCPLUGINS_DIR:= $(shell $(GCC) --print-file-name=plugin)
+GCCPLUGINS_DIR:= $(shell $(CC) --print-file-name=plugin)
GENERATOR_DEPS=cpybuilder.py wrapperbuilder.py
@@ -103,7 +101,7 @@ all: autogenerated-config.h testcpybuilder test-suite testcpychecker
plugin: autogenerated-config.h python.so
python.so: $(PLUGIN_OBJECT_FILES)
- $(GCC) $(CFLAGS) -shared $^ -o $@
+ $(CC) $(CFLAGS) -shared $^ -o $@
clean:
rm -f *.so *.o
@@ -111,7 +109,7 @@ clean:
rm -rf docs/_build
autogenerated-config.h: configbuilder.py generate-config-h.py
- $(PYTHON) generate-config-h.py -o $@ --gcc=$(GCC)
+ $(PYTHON) generate-config-h.py -o $@ --gcc=$(CC)
autogenerated-gimple-types.txt: gimple-types.txt.in
cpp $(CFLAGS) $^ -o $@
@@ -168,7 +166,7 @@ TEST_CFLAGS= \
# A catch-all test for quick experimentation with the API:
test: plugin
- $(GCC) -v $(TEST_CFLAGS) $(shell pwd)/test.c
+ $(CC) -v $(TEST_CFLAGS) $(shell pwd)/test.c
# Selftest for the cpychecker.py code:
testcpychecker: plugin
@@ -179,10 +177,10 @@ testcpybuilder:
$(PYTHON) testcpybuilder.py -v
dump_gimple:
- $(GCC) -fdump-tree-gimple $(shell pwd)/test.c
+ $(CC) -fdump-tree-gimple $(shell pwd)/test.c
debug: plugin
- $(GCC) -v $(TEST_CFLAGS) $(shell pwd)/test.c
+ $(CC) -v $(TEST_CFLAGS) $(shell pwd)/test.c
# A simple demo, to make it easy to demonstrate the cpychecker:
demo: plugin
diff --git a/configbuilder.py b/configbuilder.py
index 0bebfef..3a420bb 100644
--- a/configbuilder.py
+++ b/configbuilder.py
@@ -134,7 +134,7 @@ class ConfigBuilder:
with open(srcpath, 'w') as f:
f.write(src)
outpath = os.path.join(dirpath, 'feature-test.o')
- args= [os.environ.get('GCC', 'gcc'),
+ args= [os.environ.get('CC', 'gcc'),
'-c', # don't run the linker (no main)
'-o', outpath,
srcpath] + extraargs
diff --git a/run-test-suite.py b/run-test-suite.py
index 47d3a95..d277b3f 100644
--- a/run-test-suite.py
+++ b/run-test-suite.py
@@ -253,7 +253,7 @@ def run_test(testdir):
env['LC_ALL'] = 'C'
# Generate the command-line for invoking gcc:
- args = [os.environ.get('GCC', 'gcc')]
+ args = [os.environ.get('CC', 'gcc')]
args += ['-c'] # (don't run the linker)
args += ['-o', outfile]
args += ['-fplugin=%s' % os.path.abspath('python.so'),
diff --git a/test-builder.py b/test-builder.py
index 9a0b1ed..4540fe6 100644
--- a/test-builder.py
+++ b/test-builder.py
@@ -47,7 +47,7 @@ print sm.cu.as_str()
from subprocess import Popen, PIPE, check_call
-GCCPLUGINS_DIR = Popen([os.environ.get('GCC', 'gcc'),
+GCCPLUGINS_DIR = Popen([os.environ.get('CC', 'gcc'),
'--print-file-name=plugin'], stdout=PIPE).communicate()[0].strip()
@@ -58,7 +58,7 @@ pyconfigs = ('python2.7-config',
for pyconfig in pyconfigs:
cflags = Popen([pyconfig, '--cflags', '--ldflags'], stdout=PIPE).communicate()[0]
- args = [os.environ.get('GCC', 'gcc')]
+ args = [os.environ.get('CC', 'gcc')]
args += ['-x', 'c'] # specify that it's C
args += ['-o', 'test.so']
args += cflags.split()
diff --git a/testcpybuilder.py b/testcpybuilder.py
index 2c766cd..424bb71 100644
--- a/testcpybuilder.py
+++ b/testcpybuilder.py
@@ -69,7 +69,7 @@ class BuiltModule:
def compile_src(self, extra_cflags = None):
- self.args = [os.environ.get('GCC', 'gcc')]
+ self.args = [os.environ.get('CC', 'gcc')]
self.args += ['-o', self.modfile]
self.args += ['-I' + sc.get_python_inc(),
'-I' + sc.get_python_inc(plat_specific=True)]
12 years, 2 months
[gcc-python-plugin] (16 commits) ...Merge pull request #2 from kevin-dot-pyle/master
by David Hugh Malcolm
Summary of changes:
82d6200... Derive gcc name from $CC, not $GCC
3ea2de7... Build: add various pseudo-targets to .PHONY
5bdf352... Use $(CURDIR) instead of shell call.
4c083ca... Use pattern rules for building generated files.
c0c5a85... Split CPPFLAGS/CFLAGS/LDFLAGS.
3f76a93... Use $(RM), not explicit "rm -f".
df0fe2c... demo: reuse Python CFLAGS variable
4f4e14c... Build: rework 'tarball' to remove redundant references to o
4a34de5... Build: tarball: disallow empty version
40334a9... Build: enable out-of-tree build
99da8c8... Build: only use Python includes, not all Python CFLAGS
598c566... Build: find c-pragma.h,c-common.h regardless of gcc version
4f23afe... Build: move name 'python.so' to Make variable
687460b... Build: cpybuilder.py does not use six.py, so remove import
6816d4d... Build: prevent deletion of autogenerated-*.c
df15eee... Merge pull request #2 from kevin-dot-pyle/master
12 years, 2 months
[gcc-python-plugin] cpychecker: exclude various tests for debug builds of python
by David Hugh Malcolm
commit a29cf4f671e566a7ee92cb3d604cc6ccfb25b781
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Mon Mar 26 19:59:46 2012 -0400
cpychecker: exclude various tests for debug builds of python
run-test-suite.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/run-test-suite.py b/run-test-suite.py
index 4a9fe7c..cf815d4 100644
--- a/run-test-suite.py
+++ b/run-test-suite.py
@@ -430,12 +430,19 @@ if hasattr(sys, 'gettotalrefcount'):
exclude_test('tests/cpychecker/refcounts/PyDict_SetItem/incorrect')
exclude_test('tests/cpychecker/refcounts/PyDict_SetItemString/correct')
exclude_test('tests/cpychecker/refcounts/PyDict_SetItemString/incorrect')
+ exclude_test('tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject')
exclude_test('tests/cpychecker/refcounts/PyList_Append/correct')
exclude_test('tests/cpychecker/refcounts/PyList_Append/incorrect')
exclude_test('tests/cpychecker/refcounts/PyList_Append/incorrect-loop')
+ exclude_test('tests/cpychecker/refcounts/PyList_Append/null-newitem')
+ exclude_test('tests/cpychecker/refcounts/PyList_Append/ticket-22')
exclude_test('tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct')
exclude_test('tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple')
exclude_test('tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple')
+ exclude_test('tests/cpychecker/refcounts/PyList_Size/known-size')
+ exclude_test('tests/cpychecker/refcounts/PySequence_SetItem/correct')
+ exclude_test('tests/cpychecker/refcounts/PySequence_SetItem/incorrect')
+ exclude_test('tests/cpychecker/refcounts/PySequence_Size/correct')
exclude_test('tests/cpychecker/refcounts/PyString_AsString/correct')
exclude_test('tests/cpychecker/refcounts/PyString_AsString/incorrect')
exclude_test('tests/cpychecker/refcounts/PySys_SetObject/correct')
@@ -449,10 +456,15 @@ if hasattr(sys, 'gettotalrefcount'):
exclude_test('tests/cpychecker/refcounts/Py_BuildValue/correct-code-O')
exclude_test('tests/cpychecker/refcounts/correct_decref')
exclude_test('tests/cpychecker/refcounts/loop_n_times')
+ exclude_test('tests/cpychecker/refcounts/loops/complex-loop-conditional-1')
+ exclude_test('tests/cpychecker/refcounts/loops/complex-loop-conditional-2')
exclude_test('tests/cpychecker/refcounts/module_handling')
exclude_test('tests/cpychecker/refcounts/object_from_callback')
+ exclude_test('tests/cpychecker/refcounts/passing_dead_object')
exclude_test('tests/cpychecker/refcounts/returning_dead_object')
+ exclude_test('tests/cpychecker/refcounts/ticket-20')
exclude_test('tests/cpychecker/refcounts/unrecognized_function2')
+ exclude_test('tests/cpychecker/refcounts/unrecognized_function4')
exclude_test('tests/cpychecker/refcounts/use_after_dealloc')
exclude_test('tests/examples/spelling-checker')
12 years, 2 months
[gcc-python-plugin] cpychecker: py3k fixes
by David Hugh Malcolm
commit a23816adada13e00cec181b6b28bd4a68145307c
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Mon Mar 26 19:33:29 2012 -0400
cpychecker: py3k fixes
run-test-suite.py | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/run-test-suite.py b/run-test-suite.py
index 47d3a95..4a9fe7c 100644
--- a/run-test-suite.py
+++ b/run-test-suite.py
@@ -403,11 +403,13 @@ if six.PY3:
# The PyCObject_ API was removed in 3.2:
exclude_tests_below('tests/cpychecker/refcounts/PyCObject_FromVoidPtr')
+ exclude_tests_below('tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc')
# The following tests happen to use PyInt or PyString APIs and thus we
# exclude them for now:
exclude_test('tests/cpychecker/refcounts/function-that-exits') # PyString
exclude_test('tests/cpychecker/refcounts/GIL/correct') # PyString
+ exclude_test('tests/cpychecker/refcounts/handle_null_error') # PyString
exclude_test('tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang') # PyString
exclude_test('tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct') # PyString
exclude_test('tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect') # PyString
12 years, 2 months