aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Makefile
AgeCommit message (Collapse)AuthorFilesLines
2024-01-29llvm: allow arm64Luc Van Oostenryck1-1/+1
Currently, all architectures but the i386/x86 ones are excluded from the LLVM backend, mainly because the lack of testing. Since I can test it now, allow arm64/aarch64 too. Note: this patch is somehow incomplete because the layout is not set but it's not clear what exactly the layout is needed for and at least it allows to run the testsuite on this architecture. Signed-off-by: Luc Van Oostenryck <lucvoo@kernel.org>
2024-01-20llvm: suppress warnings about deprecated APILuc Van Oostenryck1-0/+3
LLVM-14 still support LLVMBuildCall() and friends but deprecated them via the attribute, so warnings are issued when compiling. Suppress these warnings to keep builds clean. Signed-off-by: Luc Van Oostenryck <lucvoo@kernel.org>
2021-09-06Sparse v0.6.4v0.6.4Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2021-09-01Sparse v0.6.4-rc1v0.6.4-rc1Luc Van Oostenryck1-1/+1
2021-04-17Merge branch 'schecker'Luc Van Oostenryck1-0/+7
* add a symbolic checker
2021-04-13scheck: add a symbolic checkerLuc Van Oostenryck1-0/+7
Some instruction simplifications can be quite tricky and thus easy to get wrong. Often, they also are hard to test (for example, you can test it with a few input values but of course not all combinations). I'm used to validate some of these with an independent tool (Alive cfr. [1], [2]) which is quite neat but has some issues: 1) This tool doesn't work with Sparse's IR or C source but it needs to have the tests written in its own language (very close to LLVM's IR). So it can be used to test if the logic of a simplification but not if implemented correctly. 2) This tool isn't maintained anymore (has some bugs too) and it's successor (Alive2 [3]) is not quite as handy to me (I miss the pre-conditions a lot). So, this patch implement the same idea but fully integrated with Sparse. This mean that you can write a test in C, let Sparse process and simplify it and then directly validate it and not only for a few values but symbolically, for all possible values. Note: Of course, this is not totally stand-alone and depends on an external library for the solver (Boolector, see [4], [5]). Note: Currently, it's just a proof of concept and, except the included tests, it's only very slightly tested (and untested with anything more complex than a few instructions). [1] https://blog.regehr.org/archives/1170 [2] https://www.cs.utah.edu/~regehr/papers/pldi15.pdf [3] https://blog.regehr.org/archives/1722 [4] https://boolector.github.io/ [5] https://boolector.github.io/papers/BrummayerBiere-TACAS09.pdf Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2021-03-09ssa: the sparse set is not neededLuc Van Oostenryck1-1/+0
The implementation of a 'sparse set without initialization' was somehow needed during the initial design but it's not needed anymore. So, remove the implementation and replace its use by the usual bb->generation mechanism. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2021-01-27Makefile: fix version.h dependenciesKyle Russell1-1/+2
This guarantees the generated version.h will exist before attempting to compile any c files that include it. Several source files include the generated version.h, but not all declare a proper make dependency. $ grep -r 'version\.h' *.c compile-i386.c:#include "version.h" lib.c:#include "version.h" options.c:#include "version.h" This allows a sufficiently parallelized make invocation to encounter ENOENT. CC compile-i386.o compile-i386.c:60:21: fatal error: version.h: No such file or directory compilation terminated. Makefile:253: recipe for target 'compile-i386.o' failed make: *** [compile-i386.o] Error 1 Signed-off-by: Kyle Russell <bkylerussell@gmail.com> [luc.vanoostenryck@gmail.com: modified so that only version.c depends on version.h] Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-10-18Sparse v0.6.3v0.6.3Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-10-12Sparse v0.6.3-rc1v0.6.3-rc1Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-10-08build: rule for validation needs to be FORCEdLuc Van Oostenryck1-1/+1
The Makefile contains a rule for launching a test from the testsuite but we want these tests to run even if when their dependencies are up-to-date. So, add 'FORCE' in the dependency list. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-09-06testsuite: easier testing via script & makefileLuc Van Oostenryck1-2/+2
With this change, using the testsuite via the Makefile is not limited anymore to a single file. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-08-05sindex: rename it to 'semind'Alexey Gladkov1-7/+7
The name 'sindex' is already used by another package (biosquid). So it was decided to rename it to 'semind'. Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-07-13openrisc: add minimal supportLuc Van Oostenryck1-0/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-07-13sh: add minimal supportLuc Van Oostenryck1-0/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-07-13nds32: add minimal supportLuc Van Oostenryck1-0/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-07-13xtensa: add minimal supportLuc Van Oostenryck1-0/+1
This is one of the architecture needing a specific predefine set in order to correctly process byteorder.h. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-07-13h8300: add minimal supportLuc Van Oostenryck1-0/+1
This is now the only architecture needing '-msize-long'. Prepare the obsolescence of this option by adding the target file for this architecture. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-07-06arch: add minimal support for microblazeLuc Van Oostenryck1-0/+1
The Kernel Test Robot reports a problem on microblaze. The cause is that __MICROBLAZEEL__ is not defined. However, the real problem is that sparse has no support at all for this architecture. So, add the minimal support for microblaze. Link: https://lore.kernel.org/lkml/202007060542.hNfoTcsC%25lkp@intel.com Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-07-02cleanup: move predefines in a separate fileLuc Van Oostenryck1-0/+1
Now that option parsing have moved to a separate file, move everything related to predefined macros to a separate file too. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-07-02options: move option parsing in a separate fileLuc Van Oostenryck1-0/+1
lib.c contains to much things and is too hard to keep tidy. So, move everything related to option parsing in it's own file. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-21Sparse v0.6.2v0.6.2Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-18Sparse v0.6.2-rc2v0.6.2-rc2Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-18Merge branch 'misc'Luc Van Oostenryck1-1/+2
2020-06-16build: let the C++ compiler be configurableLuc Van Oostenryck1-1/+2
By default, the C compiler is 'gcc' but it can be overridden on the command line via 'make CC=...'. However, the C++ compiler (only needed for sparse-llvm) is hardcoded to 'g++'. Fix this by allowing to specify the C++ compiler via 'CXX=...' but keeping 'g++' as the default. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-14sindex: use -stdc=gnu99Luc Van Oostenryck1-0/+1
sindex use C99 for-loops: for (int i = 0, ....) No problem with this but sparse doesn't use this elsewhere yet and older compilers don't allow C99 by default. Fix this by adding '-std=gnu99' to the sindex-specific CFLAGS. Cc: Alexey Gladkov <gladkov.alexey@gmail.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-14sindex: minimal version for sqlite3 is 3.24Luc Van Oostenryck1-0/+6
sindex uses the sqlite3_str API which is only present since version 3.24 of SQLite3. Fix this by adding some checks in the Makefile and refuse to build it if the requirement is not met. Cc: Alexey Gladkov <gladkov.alexey@gmail.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-13Sparse v0.6.2-rc1v0.6.2-rc1Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-12arch: add specificities for AlphaLuc Van Oostenryck1-0/+1
The real goal here is in fact to move the alpha-specfic builtins out of the main builtins table. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-12arch: add specificities for BlackfinLuc Van Oostenryck1-0/+1
The real goal here is in fact to move the bfin-specfic builtins out of the main builtins table. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-06-12arch: add specificities for Nios2Luc Van Oostenryck1-0/+1
The real goal here is, in fact, to move the nios2-specfic builtins out of the main builtins table. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-05-14build: fix LLVM version detectionQuentin Monnet1-1/+2
The regex match used for detecting the LLVM version works for versions with a single-digit major number. Now that LLVM v10 is out, detection can fail, resulting in sparse-llvm not being built. Fix detection by extracting the major version number to compare with the minimum supported. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-03-11Add semantic index utilityAlexey Gladkov1-1/+11
sindex is the simple to use cscope-like tool based on sparse/dissect. Unlike cscope it runs after pre-processor and thus it can't index the code filtered out by ifdef's, but otoh it understands how the symbol is used and it can track the usage of struct members. To create an index for your linux kernel configuration: $ make C=2 CHECK="sindex add --" Now, to find where a definition of the pid field from the task_struct structure: $ sindex search -m def task_struct.pid (def) include/linux/sched.h 793 11 pid_t pid; default output format: SOURCE-FILE \t LINE-NUMBER \t COLUMN \t IN FUNCTION NAME \t CODE LINE To find where this field changes: $ sindex search -m w task_struct.pid (-w-) fs/exec.c 1154 6 de_thread tsk->pid = leader->pid; (-w-) kernel/fork.c 2155 3 copy_process p->pid = pid_nr(pid); To get only filenames and line number you can change output format: $ sindex search -f '%f:%l' -m w task_struct.pid fs/exec.c:1154 kernel/fork.c:2155 Current limitations: * inline functions are ignored; * enums are ignored; * unknown #include leads to a fatal error. Suggested-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-12-16arch: move arch-specificities to their own filesLuc Van Oostenryck1-0/+10
lib.c and even more so, target.c, become cluttered by the arch specific type initialization. It would be better to move this to arch-specific files, move the generics target related helpers to target.c and have sparse_initialize() to just call these helpers. For doing this: * introduce a struct to hold the configurations for each arch, * move the arch-specific type initialization to separate files, * make target.c generic. Also change the default types to LP64. Note: this is the first step to better handle other arch specificities like the predefines or the handling of some options. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-11-05show-type: add a test program to test do_show_type() & friendsLuc Van Oostenryck1-0/+1
Add another small client doing nothing but display the type of the toplevel symbols. This will help to test further changes in do_show_type(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-10-14Sparse v0.6.1v0.6.1Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-10-07Sparse v0.6.1-rc2 is now out.Luc Van Oostenryck1-1/+1
The source code can be found at its usual repository: git://git.kernel.org/pub/scm/devel/sparse/sparse.git v0.6.1-rc2 The tarballs are found at: https://www.kernel.org/pub/software/devel/sparse/dist/ Many thanks to people who have contributed to this release: Ben Dooks, Dan Carpenter, Jann Horn, Randy Dunlap, Thomas Weißschuh, Ramsay Jones, Linus Torvalds, Oliver Hartkopp and Ilya Maximets, Most changes since the previous release (v0.6.1-rc1) belong in 2 categories: 1) small fixes and iprovements 2) do the evaluation & expansion of ASM operands The complete list of patches are: Ben Dooks (1): .gitignore: add temporary *~ files Dan Carpenter (1): fix sign extension in casting enums Jann Horn (1): evaluate: externally_visible functions don't need a declaration Luc Van Oostenryck (32): expand: add explanation to 'conservative' add test for evaluation of invalid assignments also accept casts of AS pointers to uintptr_t man: explain role of uintptr_t & unsigned long in casts from AS pointers fix allowing casts of AS pointers to uintptr_t cgcc: fix wrong processing of -MD & -MMD constexpr: relax constexprness of constant conditionals more consistent type info in error messages shorter message for non-scalar in conditionals expand: add test for expansion of compound literals expand: add missing expansion of compound literals dissect: fix processing of ASM statements string: add helper string_expression() string: use string_expression() in parse_static_assert() asm: add test evaluation, expansion & linearization of ASM operands asm: check earlier that body & constraints are strings asm: use a specific struct for asm operands asm: keep using struct asm_operand during linearization asm: parse constraints asm: use parse_asm_constraint() to verify constraints asm: missing evaluation of asm statements asm: linearization of output memory operands is different asm: fix liveness memory operand asm: fix missing expansion of asm statements asm: arrays & functions in non-memory operand degenerate into pointers do not linearize invalid expression add test for enum sign extension remove useless optimization in cast_enum_list() asm: warn on invalid empty constraints make 'directive in argument list' clearer expand more builtins like __builtin_ffs() cleanup: make arch_msize_long static Randy Dunlap (1): problem building sparse 0.6.0 (sparse-llvm) Thomas Weißschuh (1): expand: 'conservative' must not bypass valid simplifications Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-09-02problem building sparse 0.6.0 (sparse-llvm)Randy Dunlap1-1/+1
Certain macros have to be defined in order to use the llvm DataTypes.h header file. Fixes these build errors when building sparse-llvm: CC sparse-llvm.o In file included from /usr/include/llvm-c/Types.h:17:0, from /usr/include/llvm-c/ErrorHandling.h:17, from /usr/include/llvm-c/Core.h:18, from sparse-llvm.c:6: /usr/include/llvm/Support/DataTypes.h:57:3: error: #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" # error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" ^ /usr/include/llvm/Support/DataTypes.h:61:3: error: #error "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h" # error "Must #define __STDC_CONSTANT_MACROS before " \ ^ This is from using llvm 3.8.0. Suggested-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
2019-03-01Sparse v0.6.1-rc1v0.6.1-rc1Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-02-17build: honor CFLAGS & friends from environmentUwe Kleine-König1-6/+9
Debian build scripts pass CFLAGS in the environment. However, this is ignored by Sparse's Makefile since 'CFLAGS' is unconditionaly initialized. Fix this by initializing CFLAGS to its default value using '?='. Do the same for PKG_CONFIG, DESTDIR, BINDIR, MANDIR and CHECKER_FLAGS. Note: It's useless to try to do the same for CC, LD & AR since they're builtin variables so '?= ...' is a no-op for them (unless make is called with -R). Note: This makes sparse native builds reproducible for Debian. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-02-17build: get rid of MAN1DIRLuc Van Oostenryck1-5/+8
MAN1DIR is one of the configurable build option but it seems to have few, if any, reasons to have such an option in addition of MANDIR. So, remove this variable and simplify the install rules by using an internal-only "$(bindir)" & "$(man1dir)" to replace "$(DESTDIR)$(BINDIR)" & "$(DESTDIR)$(MANDIR)/man1". Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-02-17build: always use '-Wall -Wwrite-strings'Luc Van Oostenryck1-1/+1
Currently, these options are in the configurable part of CFLAGS, like '-O2' or '-g', but since they're just warnings they can be moved to the non-optional flags. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-02-17build: CHECKER is not needed, remove itLuc Van Oostenryck1-2/+1
This variable is only used for selfcheck and there is no reasons to be configurable from the command line or the environment. So, get rid of 'CHECKER' by inlining it in the check command. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-02-08fix parallel installLuc Van Oostenryck1-6/+3
The current make rules for 'install' were mixing pure declarative and procedural style. As consequence, the binaries or the manpages could be installed before their target directory was created. Fix this by removing the rule to create these dirs and use install with the '-D' option to create them. Also remove the first prerequisites '$(INST_PROGRAMS) $(INST_MAN1)' since these are not needed (the effective install rules already depend them) and somehow misleading (it's not because they're first in the dependencies list that they will be created before the next ones). Spotted-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2019-02-01Makefile: default to LD = CCUwe Kleine-König1-1/+1
Usually the compiler is used as linker. Assuming that if someone wants to change the compiler the linker should be changed, too, simplify that use case by using "$(CC)" as linker instead of the hard coded "gcc". This also matches the behaviour of make when using the built-in rules of GNU Make which include: LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH) %: %.o $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-12-26Sparse v0.6.0v0.6.0Luc Van Oostenryck1-1/+1
2018-12-21remove -finline-functions from CFLAGSLuc Van Oostenryck1-1/+1
By default, sparse is compiled with -finline-functions but this flag as no effect on the generated code (since gcc's defaults at -O2 already do automatic inlining). So, remove this flag. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-12-18build: check if sparse-llvm needs libc++Luc Van Oostenryck1-0/+1
The output of 'llvm-config --system-libs' is not really complete as libc++ may be needed but not reported as such by this command. So, use the output of 'llvm-config --cxxflags' to check this. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-12-18build: only need includedir from llvm-configLuc Van Oostenryck1-1/+1
sparse-llvm doesn't need to full output of 'llvm-config --cflags', it only needs where LLVM's header files can be found. So, use 'llvm-config --includedir' instead. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-12-18VERSION=0.6.0-rc1Luc Van Oostenryck1-1/+1
I forgot to update the version number in the Makefile. Here it is now. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-07-01ssa: phase 1: phi-nodes placementLuc Van Oostenryck1-0/+1
This implement the first phase of classical SSA conversion: the placement of phi-nodes at the dominance frontier. The implementation is rather straight-forward: * for each pseudo used to make an access do: * reject cases that can't be converted: - volatile accesses - symbols externally visible - complex types that should not be converted * scan the concerned instructions and BBs * if there is only 1 store the loads may be directly converted (if dominated by the store!) * if all accesses are in a single BB, then no phi-nodes are needed and the accesses can be rewritten easily * otherwise we compute the iterated dominance frontier of the BBs just scanned and insert the phi-nodes there. * finally, some cleanup is done on dead stores Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-07-01ptrmap: core implementationLuc Van Oostenryck1-0/+1
Sparse currently has a memory efficient implementation for lists of pointers to some objects. These are used for 2 different purposes: - either for a simple set of objects - either as a sequence (ordered) of objects. There is also another similar need: - a map of object (aka: dictionnary, table, ...) where the only needed operations are: - add a new element (with it's key) - lookup an element via it's key - replace the element corresponding to a key The implementation done in this patch is a very simple one based on list of blocks of key-value pairs. The idea being to later switch to a dynamic structure using a hash-table as soon as the number of element reach some threshold. However, these hash-table are only needed for some huge input files (the current implementation is no worse than walking through the ptrlists). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-07-01idf: compute the iterated dominance frontierLuc Van Oostenryck1-0/+1
Conversion of some IR into SSA form requires to place so called phi-nodes where different paths for some value meet. It's important, of course to place these correctly, but it's also important to try to minimize the number of these phi-nodes. Several algorithms exist for the placing of these phi-nodes but it can be shown that, for each variable, it is suffisant to place their phi-nodes on the dominance frontier of the nodes defining this variable and since phi-nodes themselves give a new definition, to have the minimal number of phi-nodes, these phi-nodes must be paced on the iterated dominance frontier (the transitive closure of the dominance frontier of the initial defining nodes). This patch implement what's needed to compute the iterated dominance frontier of a set of nodes. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-07-01sset: add implementation of sparse setsLuc Van Oostenryck1-0/+1
Sparse set implements set operations like add, remove & test in O(1). More importantly it also allow to reset the set as a whole in O(1). It's very handy for a few things. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-07-01graph: build the CFG reverse postorder traversalLuc Van Oostenryck1-0/+1
Do a DFS on the CFG and record the (reverse) postorder. Use this order for the normal BB traversal (ep->bbs). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-06-16ir-validate: add framework for IR validationLuc Van Oostenryck1-0/+1
To be meaningful, the IR instructions and their relationships must obey some constraints. This patch add the framework for doing this kind of validation. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-06-08utils: add xmemdup() & xstrdup()Luc Van Oostenryck1-0/+1
Add small helpers for copying a memory buffer or a string into a newly allocated buffer. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-05-19increment the version number suffix it with -devLuc Van Oostenryck1-1/+1
So we can't confuse it with the official version. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-05-19Merge branch 'next' into officialLuc Van Oostenryck1-163/+171
Synch with the official tree so that it can easily be back merged with it. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-05-06Merge branches 'unop', 'describe-dirty', 'range-syntax', 'old-testcases', ↵Luc Van Oostenryck1-1/+1
'fix-redef-typedef' and 'fixes' into tip
2018-05-01build: use --dirty with 'git describe'Luc Van Oostenryck1-1/+1
This can help the developer to realize there was some uncommited changes in the tree while testing. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-05-01build: disable LLVM on x86-64-x32Luc Van Oostenryck1-0/+3
as currently, some LLVM tests fail on this environment (llvm doesn't seems to be correct on debian x32, for example the host triple is set as "x86_64-pc-linux-gnu" while something like "x86_64-linux-gnux32" is expected in order to make the difference between the two). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Acked-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
2018-05-01build: use 'filter' to do pattern matching inside the MakefileLuc Van Oostenryck1-1/+1
This is slightly less cumbersome and more direct than using grep. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Acked-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
2018-05-01build: use a variable for $(shell uname -m)Luc Van Oostenryck1-2/+3
This avoids a second call to uname later but first at all it's a preparation for more checks done on the arch. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Acked-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
2018-03-24Sparse v0.5.2v0.5.2Luc Van Oostenryck1-1/+1
Here is version 0.5.2. No changes were needed since -rc1. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-03-03bump up version to 0.5.2-RC1v0.5.2-rc1Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2018-02-24move the optimization loop in its own fileLuc Van Oostenryck1-0/+1
Once linearized, a few essentials optimizations are done but the logic of the succession of these optimizations is open-coded at the end of linearize_fn(). Obviously, this logic have nothing to do with the linearization and moving it to a separate file will help to clarify this logic and change it when needed. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-02-24'amd64' is also ok for sparse-llvmLuc Van Oostenryck1-1/+1
For sparse-llvm, the only layouts are for x86 architecture, either 32 or 64bit. So, it's not built for other archs. This is done by parsing the output of 'uname -m' but only 'i[3456]86' or 'x86' are accepted as pattern while 'amd64' is also used. Change the pattern to also accept 'amd64'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-02-20build: use -MMD for generated dependenciesLuc Van Oostenryck1-2/+2
For the autogenerated dependencies, we're not interested in the system header files, only the project's ones. So use the option '-MMD' instead of '-MD'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-02-20build: add -MP for generated dependenciesLuc Van Oostenryck1-2/+2
When an header file is removed, or more often when bisecting or more generaly when we checkout an older version where some header file didn't exist yet, we typically have generated .d files containing dependencies on a non-existing header file. In this case, make abort and complains about the dependencies that can't be met. Avoid this situation by using the '-MP' option so that GCC can automatically add a dummy rule for those header file. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: make the '%.t' rule depends on PROGRAMS tooLuc Van Oostenryck1-1/+1
The testsuite can be run on a specific testcase directly via the Makefile via a 'validation/%.t' pattern rule but this rule had no dependency on the programs being tested and thus could be run on a previous version. Fix this by adding the needed dependencies. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-06fix: build sparse-llvm on i686s too.Luc Van Oostenryck1-1/+1
In commit "f1e4ba13d (build: disable sparse-llvm on non-x86)", we wanted to disable the build of sparse-llvm on non-x86 archs but the pattern used also excluded machines like 'i686'. Fix this by using the pattern 'i[3456]86' instead. Fixes: f1e4ba13d1499407a72349b50052ae818c8d8553 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16add table to "negate" some opcodeLuc Van Oostenryck1-0/+1
Some optimizations transform an instruction opcode into another. For example, it may be needed to know the opcode corresponding to the negation of a comparison. This patch make this easy and flexible by adding a table for the relation between opcodes. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-11Makefile: provide CFLAGS for command line override.Christopher Li1-9/+9
Avoid assign to CFLAGS in Makefile. Rename BASIC_CFLAGS to COMMON_CFLAGS. Use PKG_CFLAGS to store external package related cflags. V4: As point out by Luc, sparse-llvm.sc is missing the $(LLVM_CFLAGS). Signed-off-by: Christopher Li <sparse@chrisli.org> Acked-by: Jeff Layton <jlayton@kernel.org>
2017-11-10Makefile: use locally built sparse in the selfcheck targetRamsay Jones1-1/+1
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: let -fno-strict-aliasing be a mandatory flagLuc Van Oostenryck1-1/+6
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: add rule to run a single testLuc Van Oostenryck1-0/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use a single space before assignmentsLuc Van Oostenryck1-2/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: reorg & add commentLuc Van Oostenryck1-8/+9
No functionnal changes here, only shuffling a few lines around, adding separators and adding a few comments Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: avoid foreachLuc Van Oostenryck1-9/+11
(g)make foreach can be quite handy but it also make Makefiles much less declarative and thus harder to read. Avoid them by adding the few needed assignments & dependencies. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: add *.o to clean-check patternLuc Van Oostenryck1-0/+1
.o files are also created in the validation directory (currently only tmp.o, for sparse-llvm/sparsec testing). Aso remove them during make clean-check. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: simplify clean patternLuc Van Oostenryck1-7/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: simplify quiet commandsLuc Van Oostenryck1-13/+12
The current mechanism for the quiet commands, what's hiding the true command and emitting instead things like: CC target.o is, IMO, somehow unneedlessly sophisticated and this doesn't help to understand what's happening and to adapt things when needed. Change this by using simple 'echo' commands and make's '@' to display the short command and hiding the long one. Warning: There is a small change in behaviour with this: previously, when displaying the non-quiet commands with 'make V=1' the quiet ones were not emitted. Now, with this patch, the short/quiet command is emitted in both case. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: let quiet commands use less indentationLuc Van Oostenryck1-8/+8
Now it does the same as done in the kernel: 2 + 8. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: remove unused QUIET_INST_SHLuc Van Oostenryck1-1/+0
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use standard rules for installLuc Van Oostenryck1-21/+14
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: allow the name 'local.mk' to be configurable via the environmentLuc Van Oostenryck1-1/+2
So people who like this file to be a hidden one or to be an out-of-tree file or simply who don't like the name, can choose whatever suits them the best. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use one line per itemLuc Van Oostenryck1-8/+43
This help to minimize merge conflicts. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: remove the dist rule since unusedLuc Van Oostenryck1-7/+0
The last .tar.gz was for v0.5.0 in 2014. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: normalize rulesLuc Van Oostenryck1-2/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: remove rule for shared lib, it's unusedLuc Van Oostenryck1-15/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: make clean targets quieterLuc Van Oostenryck1-2/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: move clean & clean-check togetherLuc Van Oostenryck1-3/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: remove references to unexisting pre-process.hLuc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: add note about overwritable varsLuc Van Oostenryck1-0/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: only generate version.h when neededUwe Kleine-König1-8/+14
This way version.h isn't generated when running $(make clean) but only when lib.c is about to be compiled. This simplifies packaging for Debian because the package building programs abort when there are additional files after $(make clean). Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: move tests near their useLuc Van Oostenryck1-38/+41
No functional changes here, just moving things around. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: CHECKER_FLAGS=-Wno-vla for all targetsLuc Van Oostenryck1-3/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: reuse rule for ALL_OBJSLuc Van Oostenryck1-3/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: no need to use wildcards for generated dependenciesLuc Van Oostenryck1-4/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use $LIBS directly in the dependency listLuc Van Oostenryck1-2/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: avoid rule-specific CFLAGSLuc Van Oostenryck1-1/+1
Those are not evil but it's for consistency with the remaining. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: allow CFLAGS & friends from command lineLuc Van Oostenryck1-3/+3
This allow distros or devs to override the default CFLAGS, CPPFLAGS, LDFLAGS, ... Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: allow target-specific CFLAGS, CPPFLAGS, LDFLAGS & LDLIBSLuc Van Oostenryck1-8/+11
This a preparatory step to allow these flags to be overriden from the command line. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use '-ldlibs' instead of '_EXTRA_OBJS'Luc Van Oostenryck1-4/+4
Some of the programs need to link with some external libraries. For some reasons, these libraries are specified via variables named: "<target>_EXTRA_OBJS". Use the '-ldlibs' prefix instead to better reflect the real use. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use '-objs' instead of '_EXTRA_DEPS'Luc Van Oostenryck1-6/+6
Some programs are composed of several source files other than the main one. These files need then to be added at linking time. These extra file are currently specified using variables named "<program-name>_EXTRA_DEPS" but the way these variables are used make that they can only hold .o files (or .a ones) and are not some kind of generic dependencie. Make this explicit by using the suffix '-objs' instead. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10Makefile: use locally built sparse in the selfcheck targetRamsay Jones1-1/+1
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-11-06build: remove unused support for pkgconfigLuc Van Oostenryck1-24/+3
Sparse being a library was installed as such and with support for pkgconfig. However, it seems that sparse is only used for its tools and not as a library (at least not as an external one) and currently doesn't offer a stable interface. For now, remove the support for this, it will be easy enough to restore it if there is a new need. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-06build: fix effectiveness of generated dependenciesLuc Van Oostenryck1-1/+1
Commit fb8734e3f "Makefile: clean up and simplify" added blindly $(LIB_H) as dependency to all .o targets. This completely defeat the purpose of generated dependencies. Fix this by removing this unneeded dependency. Fixes: fb8734e3fa18619277f54f131a9b898ce7171645 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-06build: pass CPPFLAGS to compilerUwe Kleine-König1-2/+2
Debian packages use CPPFLAGS to pass -D_FORTIFY_SOURCE=2 for hardening. Originally-by: Uwe Kleine-König <uwe@kleine-koenig.org> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-06build: drop -g from LDFLAGSUwe Kleine-König1-1/+0
-g is a compiler option that is ignored by the linker. So it should be included in CFLAGS (it already is) but not LDFLAGS. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-06build: drop BASIC_CFLAGS and ALL_CFLAGSUwe Kleine-König1-9/+7
There is no good reason to not use plain CFLAGS for all usages. This simplifies understanding the Makefile for the casual reader. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-06build: put comment about local.mk to the place where it is includedUwe Kleine-König1-5/+4
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-05build: make PREFIX overwritable from the environmentUwe Kleine-König1-1/+1
This way I can just use env PREFIX=/usr make install on the command line to install sparse into the system. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-10-02build: remove version.h in clean targetUwe Kleine-König1-1/+1
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-09-12build: disable sparse-llvm on non-x86Luc Van Oostenryck1-0/+4
sparse-llvm doesn't have support for targets other than x86 or x86-64. Disable sparse-llvm on other archs as it create problems during build, selftest, ... Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-08-17Sparse 0.5.1Christopher Li1-1/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-08-11Bump sparse's version to -rc5v0.5.1-rc5Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-08-10test-inspect: Detect gtk3 then gtk2 packageChristopher Li1-7/+14
This fix a bug that test-inspect crash on Ubuntu 16.04 TLS updated vesion of gtk2. gtk3 does not seem to have this problem. Detect and use gtk3 if exists. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-08-09Makefile: pass -Wno-vla to sparse while checking pre-process.cRamsay Jones1-1/+4
Introduce a $(CHECKER_FLAGS) variable to allow adding flags, using target specific variable assignments, to specific $(CHECKER) command invocations. In particular, in a new pre-process.cs target, include '-Wno-vla' in the flags while checking pre-process.c. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2017-08-09Makefile: add selfcheck targetChristopher Li1-2/+12
"make selfcheck" will invoke sparse to check its own source code. It is different than the "make C=1" in linux kernel because sparse executable need to be compiled first. "make <filename>.sc" will invoke the sparse to check specific C source file <filename>.c For example: "make parse.sc" V2: As pointer out by Ramsay Jones, in cygwin the check need to be invoked by cgcc to have some platform specific macro defined. Change the checker program to control by $(CHECKER) Add $(PROGRAM)_EXTRA_DEPS into selfcheck Signed-off-By: Christopher Li <sparse@chrisli.org>
2017-08-09Makefile: clean up and simplifyChristopher Li1-10/+8
- For invoke shell command, use immediate evaluation to avoid invoke more than once. - Adding header file dependency to all object files. Remove the hand specify header file dependency. - Change c2xml to target specific CFLAGS, this allow c2xml using the common pattern rules. - Ramsay Jones point out that LIBXML_CFLAGS need to be put into if HAVE_LIBXML condition. Otherwise make will spew error on system that does not have libxml Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-By: Christopher Li <sparse@chrisli.org>
2017-07-04bump sparse's version to 0.5.1-rc4v0.5.1-rc4Christopher Li1-1/+1
Signed-of-By: Christopher Li <sparse@chrisli.org>
2017-06-21bump sparse's version to -rc3Luc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-05-15add show_allocation_stats()Luc Van Oostenryck1-0/+1
There exist some function to display the stats from each allocator (show_<allocator>_alloc()) but these functions need to be called one by one and deosn't allow to make some totals. Chnage this by adding show_allocation_stats() which display (in a more consise way) the stats from every allocator, together with the totals. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-02-13move evaluation & expansion of builtins in a separate fileLuc Van Oostenryck1-0/+1
No functional changes, just move some code around and rename 'eval_init_table[]' to 'builtins_table[]'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2016-10-13Fix warning compiling sparse-llvmChristopher Li1-1/+1
-pedantic in the llvm-config --cflags cause a lot of warning. Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-11-10build: allow use of PKG_CONFIG to override pkg-configAaro Koskinen1-6/+7
Allow overriding pkg-config e.g. when cross-compiling. Signed-off-by: Aaro Koskinen <aaro.koskinen@nsn.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-10-10Add support for multiarch system header filesRamsay Jones1-0/+3
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-10-10Makefile: suppress error message from shellRamsay Jones1-9/+7
In particular, on systems which do not have 'llvm-config' installed, every invocation of make issues the following messages: /bin/sh: llvm-config: command not found make: llvm-config: Command not found A simple solution would be to suppress these messages by redirecting stderr to the bit-bucket within the definitions of HAVE_LLVM_VERSION and LLVM_VERSION. As an alternative, however, we move the definition of LLVM_VERSION down the file within the HAVE_LLVM conditional, which ensures that the 'llvm-config' command exists. In addition, the HAVE_LLVM_VERSION variable is replaced with an equivalent conditional expression. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-09-25Use LLVM_CONFIG instead of llvm-config in MakefilePavel Roskin1-1/+1
Signed-off-by: Pavel Roskin <proski@gnu.org> Reviewed-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-09-25sparse-llvm: Fix LLVM 3.5 linker errorsOmar Sandoval1-0/+1
llvm-config 3.5 no longer lists the non-LLVM libraries needed for linkage when passed --libs. The --system-libs flag was added for this purpose. This adds these libraries while silently doing nothing for older versions of LLVM. Signed-off-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-04-15build: allow use of LLVM_CONFIG to override llvm-config config scriptCody P Schafer1-6/+7
On systems like ubuntu 12.04, llvm-config is llvm 2.9, but llvm-config-3.0 and llvm-config-3.3 (for example) are versions 3.0 and 3.3 respectively. Allow overriding the name/path of the llvm-config script so people can use these versioned config scripts Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-01-29Sparse 0.5.0v0.5.0Christopher Li1-1/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-01-29Fix make dist failureChristopher Li1-1/+1
This bug was introduced in commit bcdb5ee5. The SPARSE_VERSION already starts with 'v'. Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-12-21Sparse 0.5.0 rc1Christopher Li1-1/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-05-15Trivial: Remove redundant Makefile variableChristopher Li1-2/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-05-15sparse, llvm: fix link errorsXi Wang1-2/+2
This patch fixes the following link errors. libLLVMSupport.a(Signals.o): In function `llvm::sys::PrintStackTrace(_IO_FILE*)': Signals.inc:269: undefined reference to `dladdr' Signals.inc:281: undefined reference to `dladdr' Cc: Pekka Enberg <penberg@kernel.org> Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-03-06There's no current way to know the versionJoe Perches1-1/+9
of sparse. Add --version to see it. Reviewed-by: Joe Perches <joe@perches.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-02-13Merge git://git.kernel.org/pub/scm/linux/kernel/git/viro/sparse into margeChristopher Li1-1/+1
Pull preprocessor fix from Al Viro. 1) we really, really shouldn't convert escape sequences too early; #define A(x) #x A('\12') should yield "'\\12'", *not* "'\\n'". 2) literal merging handles all sequences of string/wide string literals; result is wide if any of them is wide. string_expression() is handling that wrong - "ab"L"c" is L"abc" 3) with support (no matter how cursory) of wide char constants and wide string literals, we really ought to handle #define A(x,y) A(L,'a') properly; it's not that tricky - combine() needs to recognize <IDENT["L"],CHAR> and <IDENT["L"],STRING> pairs. 4) '\777' is an error, while L'\777' is valid - the value should fit into unsigned char or unsigned counterpart of wchar_t. Note that for string literals this happens *after* phase 6 - what matters is the type of literal after joining the adjacent ones (see (2) above). 5) stringifying should only quote \ and " in character constants and string literals, #define A(x) #x A(\n) should produce "\n", not "\\n" 6) we are losing L when stringifying wide string literals; that's wrong. I've patches hopefully fixing the above. Basically, I delay interpreting escape sequences (past the bare minimum needed to find where the token ends) until we are handling an expression with character constant or string literal in it. For character constants I'm keeping the token body in token->embedded - 4-character array replacing token->character. That covers practically all realistic instances; character constant *may* be longer than that, but it has to be something like '\x000000000000000000000000041' - sure, that's 100% legitimate C and it's going to be the same as '\x41' on everything, but when was the last time you've seen something like that? So I've split TOKEN_CHAR into 5 values - TOKEN_CHAR+1--TOKEN_CHAR+4 meaning 1--4 characters kept in ->embedded[], TOKEN_CHAR itself used for extremely rare cases longer than that (token->string holds the body in that case). TOKEN_WIDE_CHAR got the same treatment. AFAICS, with those fixes we get the same behaviour as in gcc for silently ignored by cpp if the string/char constant doesn't make it out of preprocessor. sparse still warns about those. The situation with this one is frustrating; on one hand C99 is saying that e.g. '\x' is not a token. Moreover, in a footnote in 6.4.4.4 it flat-out requires diagnostics for such. On the other hand... footnotes are informative-only and having "other character" token match ' would puts us in nasal daemon country, so gcc is free to do whatever it feels like doing. I think we shouldn't play that kind of standard-lawyering *and* sparse has always warned on that, so I've left that warning in place. Note that real wchar_t handling is still not there; at the very least, we need to decide what type will be used for that sucker (for gcc it's int on all targets we care about), fix the handling of wide string literals in initializers and evaluate_string() and stop dropping upper bits in get_string_constant(). That would probably mean not using struct string for wide ones, as well... Hell knows; I don't want to touch that right now. If anything, I'd rather wait until we get to C11 support - they've got much saner variants of wide strings there (char16_t/char32_t with u and U as token prefix as L is used for wchar_t; there's also u8"..." for UTF8 strings).
2013-02-12switch to delayed handling of escape sequencesAl Viro1-1/+1
#define A(x) #x A('\12') should *not* yield "'\\n'"; the problem is that we are doing the conversion too early. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-01-02Merge branch 'sparse-llvm' of git://github.com/penberg/sparse-llvm.gitChristopher Li1-1/+25
'master' branch of git://github.com/penberg/sparse-llvm.git Revert "sparse: Bump up sizeof(_Bool) to 8 bits" sparse, llvm: Add test case for <stdbool.h> type sparse, llvm: Use LLVMInt1Type() in sym_basetype_type() sparse, llvm: Don't fail the build if LLVM is too old Merge pull request #6 from jgarzik/hacks sparse, llvm: add loop testcase sparse, llvm: Fix loops, by properly handling OP_PHI forward references sparse, llvm: FP comparison op code generation sparse, llvm: Simplify comparison op code generation sparse, llvm: More comparison ops code generation sparse, llvm: OP_SET_B and OP_SET_A code generation sparse, llvm: Pointer cast code generation sparse, llvm: Make llc output to stdout in sparsec sparse, llvm: Fix 'extern' symbol code generation sparse, llvm: Fix symbol initializer code generation sparse, llvm: Function pointer code generation sparse, llvm: Make 'sparsec' error handling more robust sparse, llvm: Add support for union types sparse, llvm: Add support for array types sparse, llvm: Fix symbol_type() for bitfields and enums sparse, llvm: Fix struct code generation sparse, llvm: Use new LLVM type system API for structs sparse, llvm: Fix 'void *' pointer code generation sparse, llvm: Add support for logical ops sparse: Bump up sizeof(_Bool) to 8 bits sparse, llvm: Add support for symbol initializers sparse, llvm: Add support for struct types sparse, llvm: Fix code generation for 'long double' data type Merge pull request #4 from jgarzik/hacks sparse, llvm: support OP_STORE sparse, llvm: move OP_COPY support to separate function. Add FP support. sparse, llvm: store module-local functions on function reference list llvm, sparse: Fix symbol_is_fp_type() goof Merge branch 'master' of github.com:penberg/sparse-llvm Merge pull request #3 from jgarzik/hacks sparse, llvm: Fix pseudo_type() for PSEUDO_ARG sparse, llvm: create helper for obtaining instruction's type sparse, llvm: Fix code generation for casts Revert "sparse, llvm: Don't redefine module local functions" sparse, llvm: Don't redefine module local functions sparse, llvm: Fix PSEUDO_OP code generation sparse, llvm: Improve sparsec front-end sparse, llvm: Fix OP_CAST to use zero-extend sparse, llvm: Cleanup output_data() sparse, llvm: Code generation for string constants sparse, llvm: Warn the user when we fall back to GCC Limit usage of g++ to llvm related programs. Merge pull request #2 from jgarzik/hacks sparse, llvm: move OP_CAST code to separate func. support FP casts. cse: update PHI users when throwing away an instruction cse: treat PHI-nodes as other instructions Merge pull request #1 from jgarzik/hacks sparse, llvm: move OP_PHI code from switch statement to separate function sparse, llvm: implement OP_CALL sparse, llvm: replace FIXME comment with assert(), following existing style sparse-llvm OP_PHISOURCE: replace copy with target=src pointer operation sparse, llvm: Kill debugging code sparse, llvm: Kill ifdef'd unssa() call sparse, llvm: Bitwise not operator codegen sparse, llvm: Reorganize code generation tests sparse, llvm: Floating point support for binops sparse-llvm: OP_LOAD sparse-llvm: OP_SWITCH sparse-llvm: OP_SEL sparse, llvm: if-else code generation sparse, llvm: Implement OP_CAST sparse, llvm: Move binop tests to validation/backend sparse, llvm: Implement some binary comparison ops sparse, llvm: Add support for more binary ops sparse, llvm: Implement OP_ADD sparse, llvm: Add output_op_binary() stub sparse, llvm: Introduce 'struct function' to clean up code sparse, llvm: Add support for OP_RET/PSEUDO_ARG sparse, llvm: OP_RET/PSEUDO_VAL code generation sparse, llvm: Add switch statement to output_insn() llvm, sparse: Separate entry and exit basic blocks sparse, llvm: Fix 'sparsec' when it's not in PATH sparse, llvm: Fix global variable initialization sparse, llvm: Fix assert() in sparse code sparse, llvm: Initial commit
2011-11-25sparse, llvm: Don't fail the build if LLVM is too oldPekka Enberg1-3/+10
Disable sparse-llvm compilation if LLVM version is too old. Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Christopher Li <sparse@chrisli.org> Cc: Jeff Garzik <jgarzik@redhat.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
2011-11-21sparse 0.4.4v0.4.4Christopher Li1-1/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-08-29Sparse 0.4.4-rc2v0.4.4-rc2Christopher Li1-1/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-08-28Limit usage of g++ to llvm related programs.Christopher Li1-2/+3
Signed-off-by: Christopher Li <sparse@chrisli.org> Signed-off-by: Pekka Enberg <penberg@kernel.org>
2011-08-23sparse, llvm: Fix 'sparsec' when it's not in PATHPekka Enberg1-1/+1
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2011-08-23sparse, llvm: Fix assert() in sparse codePekka Enberg1-1/+1
Don't let 'llvm-config' define NDEBUG because it disables assert(). Signed-off-by: Pekka Enberg <penberg@kernel.org>
2011-08-23sparse, llvm: Initial commitPekka Enberg1-1/+17
This is the first commit to implementing a LLVM backend for sparse using the LLVM C bindings. Signed-off-by: Pekka Enberg <penberg@kernel.org>
2011-08-20Sparse 0.4.4-rc1v0.4.4-rc1Christopher Li1-1/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-04-25Allow overwrite CFLAGS from command lineChristopher Li1-6/+7
This is suggested by Diego Elio Pettenò <flameeyes@gmail.com>. CFLAGS now can be overwrited from command line as well. Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-04-18build: add an all-installable target that builds the targets to install.Diego Elio Pettenò1-1/+3
This is useful for distributions that don't want to build content that won't be installed. Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-04-18build: allow easy override of GCC_BASEDiego Elio Pettenò1-1/+2
Sometimes gcc reports the wrong path for its own base (for instance when ICC is present in the same system); by allowing an override of GCC_BASE in Makefile, it's easier for packages to fix this up. Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-03-11Makefile: warn user when libxml and/or libgtk2 are not availableFlorian Fainelli1-0/+4
Since sparse's c2xml is not always packaged my modern distributions, it can be built as a host package in build systems, finding out why c2xml was not compiled turned out to be easier if a warning was emitted, add two for libxml and libgtk2 presence/absence. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-09-02sparse 0.4.3 finialv0.4.3Christopher Li1-1/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-07-13inspect: Add test-inspect programChristopher Li1-3/+14
The test program will launch a gtk treeview windows to display the symbol node in the AST. Signed-Off-By: Christopher Li <sparse@chrisli.org>
2010-03-28Makefile: fix permissions mixup on installDan McGee1-7/+12
`install` by default uses 755 permissions; for everything but executables we want to use 644 permissions. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-03-28Simplify Makefile using static pattern rulesChristopher Li1-8/+3
I find a way to get rid of the macro and $$ in linking executable program. Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-10-11Sparse 0.4.2v0.4.2Christopher Li1-2/+2
Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-07-20Makefile: suppress error message from pkg-configRamsay Jones1-1/+1
In particular, on systems which do not have 'pkg-config' installed, every invocation of make issues the following message: /bin/sh: pkg-config: command not found Suppress the message by redirecting stderr to the bit-bucket. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-07-18Have Makefile import local.mk if it exists.Samuel Bronson1-2/+8
This will allow users to override build settings without dirtying their trees, making life with `git stash' a bit easier. Signed-off-by: Samuel Bronson <naesten@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2008-12-28Clean up Makefile long linesChristopher Li1-14/+17
Signed-Off-By: Christopher Li<sparse@chrisli.org>
2008-12-28Makefile automatic header dependencyChristopher Li1-77/+21
It use the gcc generated dependency file to track header file changes. Use pattern rules to build programes. Makefile is much shorter now. Easier to add new objs or new programs. Signed-Off-By: Christopher Li<sparse@chrisli.org>
2008-12-18Set gcc include path at runtime.Alexey Zaytsev1-4/+3
You can now tell sparse where to look for the compiler headers with -gcc-base-dir <dir>. Otherwise sparse will look for headers used to build it. Also adds $GCC_BASE/include-fixed used by newer gcc versions. Signed-off-by: Alexey zaytsev <alexey.zaytsev@gmail.com>
2008-12-18Gdb macros to get a better look at some sparse data structures.Alexey Zaytsev1-9/+11
Note that we need to build sparse with -g3 -gdwarf-2 to get the cpp macros included into the debug ingo. Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
2007-11-13Makefile: VERSION=0.4.10.4.1Josh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-09-19fix install perms of manpagesMike Frysinger1-1/+1
the install step for manpages currently does not use the -m option which means perms default to 755 which makes no sense for man pages Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2007-09-15Makefile: VERSION=0.40.4Josh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-09-15Add a manpage for cgccJosh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-09-15Makefile: Use ?= to allow overriding OS or AR on the Make command lineJosh Triplett1-2/+2
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-09-06Use -fno-strict-aliasing, as the ptrlist code seems to violate C99 strict ↵Josh Triplett1-1/+1
aliasing rules Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-08-31Install the Sparse manpageJosh Triplett1-0/+7
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-08-09libxml compile fix on CygwinKovarththanan Rajaratnam1-1/+1
Hello, I needed to re-arrange the libxml-2.0 library order to make sparse compile on Cygwin. Patch attached. Signed-off-by: Kovarththanan Rajaratnam <krj@rajaratnam.dk>
2007-08-04Makefile: improve flag handlingMike Frysinger1-4/+5
Tweak the makefile so that it respects CFLAGS set in the environment and it makes sure to link the shared libsparse with $(LDFLAGS). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2007-07-30Drop -fpic; it hurts performance and we don't build libsparse.so by defaultJosh Triplett1-1/+7
Sparse doesn't have a stable shared library interface, and doesn't build libsparse.so by default. However, it used -fpic, which incurred a noticeable performance hit. Remove -fpic from the default CFLAGS, and add a comment near the definition of LIBS about adding it back if building a shared library. You probably want to build Sparse twice if you want a shared library: once without -fpic to build the Sparse tools, and again with -fpic to build the shared library. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-30Add some missing dependencies in the MakefileJosh Triplett1-0/+2
ptrlist.o didn't depend on $(LIB_H); in particular, it didn't depend on compat.h, which manifested in "bad allocation size" errors when changing the chunk size in compat.h and running "make" without "make clean". test-unssa.o also didn't depend on $(LIB_H). Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-29Makefile: Use -O2 -finline-functions, not just -OJosh Triplett1-1/+1
This makes debugging more difficult by default, but as usual, developers can change CFLAGS if they want to use a debugger; the default CFLAGS should cater to users. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-22Makefile: stop cleaning files we didn't make and have no business cleaningJosh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-22Fix test-suite to handle stdout and stderr separately, and fix up testsJosh Triplett1-2/+7
test-suite merged stdout and stderr, which relied on the ordering of data from the two streams in the merged stream. This made test-suite frequently fail on tests with both output and errors, when the ordering didn't happen to match what the test assumed. Handle each of the streams separately, and update the tests accordingly. Also clean up the output of "test-suite format" to avoid outputting values equal to the defaults. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-14Split c2xml build rule into compile and link stages, and add the quiet prefixesJosh Triplett1-5/+5
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-13add c2xml programRob Taylor1-0/+15
Adds new c2xml program which dumps out the parse tree for a given file as well-formed xml. A DTD for the format is included as parse.dtd. Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk> [Josh: DTD fixes] Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-08Make clean depend on clean-checkJosh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-07-08test-suite: a tiny test automation scriptDamien Lespiau1-0/+7
This patch introduces test-suite, a simple script that makes test cases verification easier. Test cases in the validation directory are annotated and this script parses them to check if the actual result is the one expected by the test writer. Signed-off-by: Damien Lespiau <damien.lespiau@gmail.com>
2007-06-01Makefile prettyprinting: make INSTALL and other output line up correctlyJosh Triplett1-4/+4
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-06-01Change "LD" to "LINK" in Makefile prettyprinting.Josh Triplett1-14/+14
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-05-22Remove extra space.Josh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-05-22Beautify all & install Makefile targetsDamien Lespiau1-27/+43
Beautify make's output like kbuild or git. The install target is especially much more readable. make V=1 (install) to get back to the old behaviour. Signed-off-by: Damien Lespiau <damien.lespiau@gmail.com>
2007-05-01Add a "make dist" that requires $(VERSION) to match `git describe`Josh Triplett1-0/+7
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-05-01Remove old version note.Josh Triplett1-3/+0
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-05-01Fix the version numberJosh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-02-27Move pkg-config file to lib, rather than shareJosh Triplett1-1/+1
Thanks to Jeff Garzik for pointing this out. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2007-01-16Sparse-based Ctags implementationChristopher Li1-1/+6
Here is my attempt to write a Ctags base on sparse. It depends on the result from actually preprocessing the C source file. It can handle the tags from macro expansion. It works well enough for me to locate "int32_t" and "clear_token_alloc". This is the updated ctags that actually generates output to a tags file. Signed-Off-By: Christopher Li <sparse@chrisli.org> Signed-Off-By: Josh Triplett <josh@freedesktop.org>
2006-12-05Remove old SCCS target from Makefile.0.2Josh Triplett1-2/+0
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-12-05Generate and install a pkg-config file. Add DESTDIR support to Makefile.Josh Triplett1-10/+19
The Makefile now generates and installs a pkg-config file, sparse.pc, to provide information about the installed Sparse library and header files. Use `pkg-config --cflags sparse` to get the include path, and `pkg-config --libs sparse` to get the library path and library. To help packagers of Sparse, also add support for the DESTDIR variable to the Makefile. DESTDIR allows you to target a particular prefix (such as /usr), but install to another directory (such as debian/tmp), usually for the purposes of subsequently constructing a package from that directory. Previously, just setting PREFIX would work for that, but with the new pkg-config file, the Makefile needs to know the real prefix. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-12-05Install static library and header filesJosh Triplett1-20/+17
Modify Makefile to install the static library and all of the library header files. Add dissect.h to LIB_H. Remove redundant headers from dependency lines. Remove rpath suggestion. The header files get installed to a "sparse" subdirectory of the include directory; please reference the sparse headers as sparse/${HEADER}.h. The various sparse test programs can all now compile successfully outside the sparse tree, given that modification to their #include lines. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-12-04Rename "check.c" to "sparse.c" to match program name; update .gitignoreJosh Triplett1-2/+2
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-11-06Stop building and installing libsparse.so0.1Josh Triplett1-3/+3
Since none of the header files get installed, making it difficult or impossible for anything external to use libsparse.so, and libsparse.so doesn't provide a stable API/ABI or a SONAME, and the backends all build with the static libsparse.a, stop building and installing libsparse.so. Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-11-06Install cgcc on "make install", refactor installation codePavel Roskin1-2/+5
Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-11-06Compile sparse executable under it's own name, not as "check"Pavel Roskin1-8/+3
No need to confuse everyone. Besides, it allows to use "make check" for some something meaningful in the future. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-08-29[PATCH] Add backend to graph basic blocksJosh Triplett1-1/+5
Add a new backend program which parses the input files, processes them through the linearization pass, and outputs a graphviz graph of the resulting basic blocks. Each entrypoint gets labelled by name, but for now the basic blocks just get labelled with the address of the basic_block structure. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>