Import lang/cparser, a C99 parser and frontend for libFirm.
ok bentley@ cparser is a recursive descent C99 parser written in C99. It contains a preprocessor, lexer, parser, constructs an AST and does semantic analysis. It acts as a frontend to the libFirm intermediate representation library. This way optimization and code generation is performed. The compiler supports cross compilation to multiple target architectures with a command-line switch. It comes with driver logic for calling assemblers and linkers as well as parsing command-line options. This allows it to be a drop-in replacement for gcc or clang in many situations.
This commit is contained in:
parent
24c9106815
commit
2c88f33758
36
lang/cparser/Makefile
Normal file
36
lang/cparser/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2017/11/06 01:21:07 bcallah Exp $
|
||||
|
||||
# Depends on devel/libfirm
|
||||
ONLY_FOR_ARCHS = amd64 arm i386
|
||||
|
||||
# Must keep version number in sync with devel/libfirm
|
||||
COMMENT = C99 parser and frontend for libFirm
|
||||
DISTNAME = cparser-1.22.1
|
||||
CATEGORIES = lang
|
||||
|
||||
# amd64 PIC *just* missed 1.22.0; this goes away next update
|
||||
GH_ACCOUNT = libfirm
|
||||
GH_PROJECT = cparser
|
||||
GH_COMMIT = 1930dff97172e8199c0d6f452f59dee47569d594
|
||||
|
||||
HOMEPAGE = https://pp.ipd.kit.edu/firm/
|
||||
MAINTAINER = Brian Callahan <bcallah@openbsd.org>
|
||||
|
||||
# GPLv2+
|
||||
PERMIT_PACKAGE_CDROM = Yes
|
||||
|
||||
WANTLIB += c firm m
|
||||
|
||||
# Uncomment next update
|
||||
# MASTER_SITES = https://github.com/libfirm/cparser/archive/
|
||||
|
||||
MODULES = devel/cmake
|
||||
|
||||
LIB_DEPENDS = devel/libfirm
|
||||
|
||||
NO_TEST = Yes
|
||||
|
||||
# GitHub has silly naming practices. Uncomment next update.
|
||||
# WRKDIST = ${WRKDIR}/cparser-${DISTNAME}
|
||||
|
||||
.include <bsd.port.mk>
|
2
lang/cparser/distinfo
Normal file
2
lang/cparser/distinfo
Normal file
@ -0,0 +1,2 @@
|
||||
SHA256 (cparser-1.22.1-1930dff9.tar.gz) = Q4Qul3xeLp96daMOxjoUeGRqacclBNJBlMn1SDmOTKI=
|
||||
SIZE (cparser-1.22.1-1930dff9.tar.gz) = 289387
|
14
lang/cparser/patches/patch-CMakeLists_txt
Normal file
14
lang/cparser/patches/patch-CMakeLists_txt
Normal file
@ -0,0 +1,14 @@
|
||||
$OpenBSD: patch-CMakeLists_txt,v 1.1.1.1 2017/11/06 01:21:07 bcallah Exp $
|
||||
|
||||
Install manual page correctly.
|
||||
|
||||
Index: CMakeLists.txt
|
||||
--- CMakeLists.txt.orig
|
||||
+++ CMakeLists.txt
|
||||
@@ -118,5 +118,5 @@ set(INSTALL_HEADERS
|
||||
include/stddef.h
|
||||
)
|
||||
install(FILES ${INSTALL_HEADERS} DESTINATION ${COMPILER_INCLUDE_DIR})
|
||||
-install(FILES cparser.1 DESTINATION share/man/man1)
|
||||
+install(FILES cparser.1 DESTINATION man/man1)
|
||||
install(TARGETS cparser DESTINATION bin)
|
25
lang/cparser/patches/patch-src_driver_predefs_c
Normal file
25
lang/cparser/patches/patch-src_driver_predefs_c
Normal file
@ -0,0 +1,25 @@
|
||||
$OpenBSD: patch-src_driver_predefs_c,v 1.1.1.1 2017/11/06 01:21:07 bcallah Exp $
|
||||
|
||||
cparser doesn't understand __attribute__((__gnu_inline__)).
|
||||
This causes all sorts of multiple definition linker errors.
|
||||
So let's set the GCC compatibility to too old for it.
|
||||
|
||||
Also doesn't understand _Pragma.
|
||||
Let's say we're GCC 3.4.6 (for now) because of all this.
|
||||
|
||||
Index: src/driver/predefs.c
|
||||
--- src/driver/predefs.c.orig
|
||||
+++ src/driver/predefs.c
|
||||
@@ -245,9 +245,9 @@ void add_predefined_macros(void)
|
||||
add_define("__CPARSER_PATCHLEVEL__", CPARSER_PATCHLEVEL, false);
|
||||
|
||||
/* let's pretend we are a GCC compiler */
|
||||
- add_define("__GNUC__", "4", false);
|
||||
- add_define("__GNUC_MINOR__", "6", false);
|
||||
- add_define("__GNUC_PATCHLEVEL__", "0", false);
|
||||
+ add_define("__GNUC__", "3", false);
|
||||
+ add_define("__GNUC_MINOR__", "4", false);
|
||||
+ add_define("__GNUC_PATCHLEVEL__", "6", false);
|
||||
if (dialect.cpp)
|
||||
add_define("__GNUG__", "4", false);
|
||||
|
27
lang/cparser/patches/patch-src_driver_target_c
Normal file
27
lang/cparser/patches/patch-src_driver_target_c
Normal file
@ -0,0 +1,27 @@
|
||||
$OpenBSD: patch-src_driver_target_c,v 1.1.1.1 2017/11/06 01:21:07 bcallah Exp $
|
||||
|
||||
Add OpenBSD and set it up properly.
|
||||
|
||||
Index: src/driver/target.c
|
||||
--- src/driver/target.c.orig
|
||||
+++ src/driver/target.c
|
||||
@@ -288,6 +288,10 @@ static void set_options_for_machine(machine_triple_t c
|
||||
} else if (strstr(os, "bsd") != NULL) {
|
||||
init_generic_elf();
|
||||
init_unix();
|
||||
+#if defined(__OpenBSD__)
|
||||
+ target.pic_mode = 1;
|
||||
+ ppdef( "__OpenBSD__", "1");
|
||||
+#endif
|
||||
} else if (streq(os, "elf") || streq(os, "octopos") || streq(os, "irtss")) {
|
||||
init_generic_elf();
|
||||
} else if (strstart(os, "darwin")) {
|
||||
@@ -514,6 +518,8 @@ static machine_triple_t *get_host_machine_triple(void)
|
||||
machine->operating_system = xstrdup("linux-gnu");
|
||||
#elif defined(__linux__)
|
||||
machine->operating_system = xstrdup("linux");
|
||||
+#elif defined(__OpenBSD__)
|
||||
+ machine->operating_system = xstrdup("bsd");
|
||||
#elif defined(__midipix__)
|
||||
machine->operating_system = xstrdup("midipix");
|
||||
#elif defined(__ELF__)
|
18
lang/cparser/patches/patch-src_driver_warning_h
Normal file
18
lang/cparser/patches/patch-src_driver_warning_h
Normal file
@ -0,0 +1,18 @@
|
||||
$OpenBSD: patch-src_driver_warning_h,v 1.1.1.1 2017/11/06 01:21:07 bcallah Exp $
|
||||
|
||||
Turn off -Wexperimental by default.
|
||||
The entire amd64 backend is considered experimental.
|
||||
We don't need a -Wexperimental warning for every single file compiled on amd64.
|
||||
|
||||
Index: src/driver/warning.h
|
||||
--- src/driver/warning.h.orig
|
||||
+++ src/driver/warning.h
|
||||
@@ -34,7 +34,7 @@ void print_warning_opt_help(void);
|
||||
M(WARN_ENDIF_LABELS, ON, "endif-labels", "Warn whenever an '#else' or an '#endif' are followed by text") \
|
||||
M(WARN_ENUM_CONVERSION, ON, "enum-conversion", "warn about implicit conversion between different enum types") \
|
||||
M(WARN_ERROR, OFF, "error", "Treat warnings as errors") \
|
||||
- M(WARN_EXPERIMENTAL, ON, "experimental", "Warn if experimental/unstable compiler features are used") \
|
||||
+ M(WARN_EXPERIMENTAL, OFF, "experimental", "Warn if experimental/unstable compiler features are used") \
|
||||
M(WARN_FATAL_ERRORS, OFF, "fatal-errors", "First error stops the compilation") \
|
||||
M(WARN_FLOAT_EQUAL, OFF, "float-equal", "Warn if floating point values are used in equality comparisons") \
|
||||
M(WARN_FORMAT, ON, "format", "Check printf-style format strings") \
|
9
lang/cparser/pkg/DESCR
Normal file
9
lang/cparser/pkg/DESCR
Normal file
@ -0,0 +1,9 @@
|
||||
cparser is a recursive descent C99 parser written in C99. It contains a
|
||||
preprocessor, lexer, parser, constructs an AST and does semantic
|
||||
analysis. It acts as a frontend to the libFirm intermediate
|
||||
representation library. This way optimization and code generation is
|
||||
performed. The compiler supports cross compilation to multiple target
|
||||
architectures with a command-line switch. It comes with driver logic for
|
||||
calling assemblers and linkers as well as parsing command-line options.
|
||||
This allows it to be a drop-in replacement for gcc or clang in many
|
||||
situations.
|
12
lang/cparser/pkg/PLIST
Normal file
12
lang/cparser/pkg/PLIST
Normal file
@ -0,0 +1,12 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2017/11/06 01:21:07 bcallah Exp $
|
||||
@bin bin/cparser
|
||||
lib/cparser/
|
||||
lib/cparser/1.22.1/
|
||||
lib/cparser/1.22.1/include/
|
||||
lib/cparser/1.22.1/include/float.h
|
||||
lib/cparser/1.22.1/include/iso646.h
|
||||
lib/cparser/1.22.1/include/limits.h
|
||||
lib/cparser/1.22.1/include/stdarg.h
|
||||
lib/cparser/1.22.1/include/stdbool.h
|
||||
lib/cparser/1.22.1/include/stddef.h
|
||||
@man man/man1/cparser.1
|
Loading…
x
Reference in New Issue
Block a user