skvadrik / re2c

Lexer generator for C, C++, Go and Rust.
https://re2c.org
Other
1.09k stars 170 forks source link

On Solaris 10 with strict C99 and C++ 2011 I see Error: Goto end bypasses a variable #347

Closed blastwave closed 1 year ago

blastwave commented 3 years ago

Sadly I can not provide a lot of input here however :


/opt/developerstudio12.6/bin/CC -DHAVE_CONFIG_H -I.   -I/opt/bw/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE -D_TS_ERRNO -D_X_OPEN_SOURCE=600 -W  -Wall  -Wextra  -Weffc++  -pedantic  -Wformat=2  -Wredundant-decls  -Wsuggest-attribute=format  -Wconversion  -Wsign-conversion  -Werror=return-type  -O2  -Weverything -Wno-unknown-warning-option     -Wno-reserved-id-macro     -Wno-padded -Wno-old-style-cast     -Wno-nested-anon-types -Wno-global-constructors     -Wno-shadow-field-in-constructor     -Wno-undefined-func-template -DRE2C_STDLIB_DIR='"/opt/bw/share/re2c/stdlib/"' -DRE2C_DEBUG -std=c++11 -xO0 -g -dalign -erroff=%none -errtags=yes -ftrap=%none -xcode=pic32 -m64 -xbuiltin=%none -xarch=sparc -xdepend=no -xregs=no%appl -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE -D_TS_ERRNO -c -o src/util/temp_file.o src/util/temp_file.cc
"/opt/bw/include/libintl.h", line 124: Warning, doubunder: There are two consecutive underbars in "__msgid".
"/opt/bw/include/libintl.h", line 144: Warning, doubunder: There are two consecutive underbars in "__domainname".
"/opt/bw/include/libintl.h", line 165: Warning, doubunder: There are two consecutive underbars in "__category".
"/opt/bw/include/libintl.h", line 187: Warning, doubunder: There are two consecutive underbars in "__msgid1".
"/opt/bw/include/libintl.h", line 187: Warning, doubunder: There are two consecutive underbars in "__msgid2".
"/opt/bw/include/libintl.h", line 280: Warning, doubunder: There are two consecutive underbars in "__dirname".
"/opt/bw/include/libintl.h", line 298: Warning, doubunder: There are two consecutive underbars in "__codeset".
"src/util/temp_file.cc", line 82: Error: Goto end bypasses a variable (or an exception) initialization.
"src/util/temp_file.cc", line 85: Error: Goto end bypasses a variable (or an exception) initialization.
2 Error(s) and 7 Warning(s) detected.
gmake[2]: *** [Makefile:2814: src/util/temp_file.o] Error 2
gmake[2]: Leaving directory '/export/home/dclarke/foo/re2c-2.1.1'
gmake[1]: *** [Makefile:4518: all-recursive] Error 1
gmake[1]: Leaving directory '/export/home/dclarke/foo/re2c-2.1.1'
gmake: *** [Makefile:1721: all] Error 2

Also I did not want -O2 and in fact I just wanted a default debug non-optimized compile.

-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional
blastwave commented 3 years ago

Easy enough to hack past and then we get disaster :



alpha $ diff -u ./src/util/temp_file.cc.orig ./src/util/temp_file.cc     
--- ./src/util/temp_file.cc.orig        Thu Mar  7 13:15:11 2019
+++ ./src/util/temp_file.cc     Mon Mar 29 00:38:19 2021
@@ -79,10 +79,20 @@
     bool ok = false;

     src = fopen(srcname, "r");
-    if (!src) goto end;
+    if (!src) {
+        if (src) fclose(src);
+        if (dst) fclose(dst);
+        UNLINK(ok ? srcname : dstname);
+        return ok;
+    }

     dst = fopen(dstname, "w");
-    if (!dst) goto end;
+    if (!dst) {
+        if (src) fclose(src);
+        if (dst) fclose(dst);
+        UNLINK(ok ? srcname : dstname);
+        return ok;
+    }

     static const size_t BLK = 4096;
     char buf[BLK];
@@ -93,11 +103,6 @@
     }
     ok = true;

-end:
-    if (src) fclose(src);
-    if (dst) fclose(dst);
-    UNLINK(ok ? srcname : dstname);
-
     return ok;
 }

/opt/bw/bin/bash ./libtool  --tag=CXX   --mode=link /opt/developerstudio12.6/bin/CC -W  -Wall  -Wextra  -Weffc++  -pedantic  -Wformat=2  -Wredundant-decls  -Wsuggest-attribute=format  -Wconversion  -Wsign-conversion  -Werror=return-type  -O2  -Weverything -Wno-unknown-warning-option     -Wno-reserved-id-macro     -Wno-padded -Wno-old-style-cast     -Wno-nested-anon-types -Wno-global-constructors     -Wno-shadow-field-in-constructor     -Wno-undefined-func-template -DRE2C_STDLIB_DIR='"/opt/bw/share/re2c/stdlib/"' -DRE2C_DEBUG -std=c++11 -xO0 -g -dalign -erroff=%none -errtags=yes -ftrap=%none -xcode=pic32 -m64 -xbuiltin=%none -xarch=sparc -xdepend=no -xregs=no%appl -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE -D_TS_ERRNO -module -no-undefined -L/opt/bw/lib -R/opt/bw/lib -o libre2c.la -rpath /opt/bw/lib  lib/libre2c_la-regcomp.lo lib/libre2c_la-regexec.lo lib/libre2c_la-regexec_dfa.lo lib/libre2c_la-regexec_dfa_regless.lo lib/libre2c_la-regexec_nfa_leftmost.lo lib/libre2c_la-regexec_nfa_leftmost_trie.lo lib/libre2c_la-regexec_nfa_posix.lo lib/libre2c_la-regexec_nfa_posix_trie.lo lib/libre2c_la-regexec_nfa_posix_backward.lo lib/libre2c_la-regexec_nfa_posix_kuklewicz.lo lib/libre2c_la-regfree.lo lib/libre2c_la-stubs.lo src/parse/libre2c_la-ast.lo src/parse/libre2c_la-unescape.lo src/options/libre2c_la-opt.lo src/cfg/libre2c_la-cfg.lo src/cfg/libre2c_la-compact.lo src/cfg/libre2c_la-dce.lo src/cfg/libre2c_la-freeze.lo src/cfg/libre2c_la-interfere.lo src/cfg/libre2c_la-liveanal.lo src/cfg/libre2c_la-normalize.lo src/cfg/libre2c_la-optimize.lo src/cfg/libre2c_la-rename.lo src/cfg/libre2c_la-varalloc.lo src/dfa/libre2c_la-closure.lo src/debug/libre2c_la-dump_adfa.lo src/debug/libre2c_la-dump_cfg.lo src/debug/libre2c_la-dump_dfa.lo src/debug/libre2c_la-dump_dfa_tree.lo src/debug/libre2c_la-dump_interf.lo src/debug/libre2c_la-dump_nfa.lo src/dfa/libre2c_la-dead_rules.lo src/dfa/libre2c_la-determinization.lo src/dfa/libre2c_la-fallback_tags.lo src/dfa/libre2c_la-fillpoints.lo src/dfa/libre2c_la-find_state.lo src/dfa/libre2c_la-minimization.lo src/dfa/libre2c_la-stacmd.lo src/dfa/libre2c_la-tagver_table.lo src/dfa/libre2c_la-tcmd.lo src/nfa/libre2c_la-estimate_size.lo src/nfa/libre2c_la-re_to_nfa.lo src/encoding/libre2c_la-enc.lo src/encoding/libre2c_la-range_suffix.lo src/encoding/ebcdic/libre2c_la-ebcdic_regexp.lo src/encoding/utf16/libre2c_la-utf16.lo src/encoding/utf16/libre2c_la-utf16_regexp.lo src/encoding/utf8/libre2c_la-utf8.lo src/encoding/utf8/libre2c_la-utf8_regexp.lo src/msg/libre2c_la-msg.lo src/msg/libre2c_la-warn.lo src/regexp/libre2c_la-ast_to_re.lo src/regexp/libre2c_la-default_tags.lo src/regexp/libre2c_la-fixed_tags.lo src/regexp/libre2c_la-nullable.lo src/regexp/libre2c_la-rule.lo src/regexp/libre2c_la-split_charset.lo src/regexp/libre2c_la-tag.lo src/skeleton/libre2c_la-control_flow.lo src/skeleton/libre2c_la-maxpath.lo src/skeleton/libre2c_la-skeleton.lo src/util/libre2c_la-range.lo src/util/libre2c_la-s_to_n32_unsafe.lo lib/libre2c_la-lex.lo lib/libre2c_la-parse.lo src/msg/libre2c_la-ver_to_vernum.lo   
libtool: link: /opt/developerstudio12.6/bin/CC -G -zdefs -hlibre2c.so.0 -o .libs/libre2c.so.0.0.0   lib/.libs/libre2c_la-regcomp.o lib/.libs/libre2c_la-regexec.o lib/.libs/libre2c_la-regexec_dfa.o lib/.libs/libre2c_la-regexec_dfa_regless.o lib/.libs/libre2c_la-regexec_nfa_leftmost.o lib/.libs/libre2c_la-regexec_nfa_leftmost_trie.o lib/.libs/libre2c_la-regexec_nfa_posix.o lib/.libs/libre2c_la-regexec_nfa_posix_trie.o lib/.libs/libre2c_la-regexec_nfa_posix_backward.o lib/.libs/libre2c_la-regexec_nfa_posix_kuklewicz.o lib/.libs/libre2c_la-regfree.o lib/.libs/libre2c_la-stubs.o src/parse/.libs/libre2c_la-ast.o src/parse/.libs/libre2c_la-unescape.o src/options/.libs/libre2c_la-opt.o src/cfg/.libs/libre2c_la-cfg.o src/cfg/.libs/libre2c_la-compact.o src/cfg/.libs/libre2c_la-dce.o src/cfg/.libs/libre2c_la-freeze.o src/cfg/.libs/libre2c_la-interfere.o src/cfg/.libs/libre2c_la-liveanal.o src/cfg/.libs/libre2c_la-normalize.o src/cfg/.libs/libre2c_la-optimize.o src/cfg/.libs/libre2c_la-rename.o src/cfg/.libs/libre2c_la-varalloc.o src/dfa/.libs/libre2c_la-closure.o src/debug/.libs/libre2c_la-dump_adfa.o src/debug/.libs/libre2c_la-dump_cfg.o src/debug/.libs/libre2c_la-dump_dfa.o src/debug/.libs/libre2c_la-dump_dfa_tree.o src/debug/.libs/libre2c_la-dump_interf.o src/debug/.libs/libre2c_la-dump_nfa.o src/dfa/.libs/libre2c_la-dead_rules.o src/dfa/.libs/libre2c_la-determinization.o src/dfa/.libs/libre2c_la-fallback_tags.o src/dfa/.libs/libre2c_la-fillpoints.o src/dfa/.libs/libre2c_la-find_state.o src/dfa/.libs/libre2c_la-minimization.o src/dfa/.libs/libre2c_la-stacmd.o src/dfa/.libs/libre2c_la-tagver_table.o src/dfa/.libs/libre2c_la-tcmd.o src/nfa/.libs/libre2c_la-estimate_size.o src/nfa/.libs/libre2c_la-re_to_nfa.o src/encoding/.libs/libre2c_la-enc.o src/encoding/.libs/libre2c_la-range_suffix.o src/encoding/ebcdic/.libs/libre2c_la-ebcdic_regexp.o src/encoding/utf16/.libs/libre2c_la-utf16.o src/encoding/utf16/.libs/libre2c_la-utf16_regexp.o src/encoding/utf8/.libs/libre2c_la-utf8.o src/encoding/utf8/.libs/libre2c_la-utf8_regexp.o src/msg/.libs/libre2c_la-msg.o src/msg/.libs/libre2c_la-warn.o src/regexp/.libs/libre2c_la-ast_to_re.o src/regexp/.libs/libre2c_la-default_tags.o src/regexp/.libs/libre2c_la-fixed_tags.o src/regexp/.libs/libre2c_la-nullable.o src/regexp/.libs/libre2c_la-rule.o src/regexp/.libs/libre2c_la-split_charset.o src/regexp/.libs/libre2c_la-tag.o src/skeleton/.libs/libre2c_la-control_flow.o src/skeleton/.libs/libre2c_la-maxpath.o src/skeleton/.libs/libre2c_la-skeleton.o src/util/.libs/libre2c_la-range.o src/util/.libs/libre2c_la-s_to_n32_unsafe.o lib/.libs/libre2c_la-lex.o lib/.libs/libre2c_la-parse.o src/msg/.libs/libre2c_la-ver_to_vernum.o   -R/opt/bw/lib -L/opt/bw/lib -lc   -O2 -g -m64 -xarch=sparc  
Undefined                       first referenced
 symbol                             in file

std::string::basic_string(const std::string &)                        src/parse/.libs/libre2c_la-ast.o
std::string::operator=(const std::string &)                        src/options/.libs/libre2c_la-opt.o
operator new[](unsigned long)                               lib/.libs/libre2c_la-regcomp.o
operator new(unsigned long)                               lib/.libs/libre2c_la-regcomp.o
std::__throw_out_of_range_fmt(const char*, ...)  src/debug/.libs/libre2c_la-dump_dfa_tree.o
std::string::compare(const std::string &)const                 src/regexp/.libs/libre2c_la-ast_to_re.o
std::string::append(const char*)                    src/options/.libs/libre2c_la-opt.o
std::string::append(const char*, unsigned long)                   src/options/.libs/libre2c_la-opt.o
std::string::append(const std::string &)                   src/options/.libs/libre2c_la-opt.o
std::string::_M_rep()const                     src/regexp/.libs/libre2c_la-rule.o
std::string::push_back(char)                   src/options/.libs/libre2c_la-opt.o
std::string::operator+=(const std::string &)                        src/msg/.libs/libre2c_la-msg.o
std::__throw_length_error(const char*)       lib/.libs/libre2c_la-regcomp.o
__cxa_guard_release                 src/regexp/.libs/libre2c_la-fixed_tags.o
std::string::basic_string()                           src/msg/.libs/libre2c_la-msg.o
std::string::~basic_string()                           lib/.libs/libre2c_la-regcomp.o
__atomic_fetch_add_8                lib/.libs/libre2c_la-regcomp.o
__cxxabiv1::zero_ints(void*, unsigned long)       src/msg/.libs/libre2c_la-warn.o
__cxa_end_catch                     lib/.libs/libre2c_la-regcomp.o
std::string::_M_data()const                    src/regexp/.libs/libre2c_la-ast_to_re.o
__cxa_begin_catch                   lib/.libs/libre2c_la-regcomp.o
std::string::empty()const                      src/options/.libs/libre2c_la-opt.o
std::allocator<char>::allocator(const std::allocator<char>&)                     lib/.libs/libre2c_la-regcomp.o
std::_Rb_tree_increment(std::_Rb_tree_node_base*) src/dfa/.libs/libre2c_la-closure.o
operator delete[](void*)                              lib/.libs/libre2c_la-regexec_nfa_posix_backward.o
operator delete(void*)                              lib/.libs/libre2c_la-regcomp.o
std::string::basic_string(const char*, const std::allocator<char>&)                  lib/.libs/libre2c_la-regcomp.o
std::string::rbegin()                      src/options/.libs/libre2c_la-opt.o
__SUNW_ABIG3_cpp_personality        lib/.libs/libre2c_la-regcomp.o
std::string::_Rep::_S_empty_rep_storage   lib/.libs/libre2c_la-regcomp.o
[Hint: static member std::string::_Rep::_S_empty_rep_storage must be defined in the program]

std::string::compare(const char*)const                  src/regexp/.libs/libre2c_la-nullable.o
std::string::basic_string(const char*, unsigned long, const std::allocator<char>&)                 src/msg/.libs/libre2c_la-ver_to_vernum.o
std::__throw_bad_alloc()            lib/.libs/libre2c_la-regcomp.o
_Unwind_Resume                      lib/.libs/libre2c_la-regcomp.o
__cxxabiv1::register_exit_code(void (*)(void)extern"C") src/parse/.libs/libre2c_la-ast.o
std::string::operator=(const char*)                         src/options/.libs/libre2c_la-opt.o
std::string::operator=(std::string &&)                         src/options/.libs/libre2c_la-opt.o
std::allocator<char>::~allocator()                        lib/.libs/libre2c_la-regcomp.o
std::allocator<char>::~allocator()                        lib/.libs/libre2c_la-regfree.o
std::allocator<char>::allocator()                        lib/.libs/libre2c_la-regcomp.o
std::terminate()                     lib/.libs/libre2c_la-regcomp.o
std::_Rb_tree_increment(const std::_Rb_tree_node_base*) lib/.libs/libre2c_la-regfree.o
std::_Rb_tree_decrement(const std::_Rb_tree_node_base*) src/regexp/.libs/libre2c_la-split_charset.o
std::string::operator+=(const char*)                         src/msg/.libs/libre2c_la-msg.o
std::string::reserve(unsigned long)                     src/options/.libs/libre2c_la-opt.o
__cxxabiv1::zero_ptrs(void*, unsigned long)       src/dfa/.libs/libre2c_la-dead_rules.o
__cxxabiv1::vector_del(void*, unsigned long, void (*)(void*)) src/cfg/.libs/libre2c_la-interfere.o
std::string::_Rep::_M_dispose(const std::allocator<char>&)      src/regexp/.libs/libre2c_la-ast_to_re.o
std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&) src/parse/.libs/libre2c_la-ast.o
std::string::_Rep::_M_destroy(const std::allocator<char>&)      lib/.libs/libre2c_la-regcomp.o
__cxa_guard_acquire                 src/regexp/.libs/libre2c_la-fixed_tags.o
std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&) lib/.libs/libre2c_la-regcomp.o
std::string::_S_compare(unsigned long, unsigned long)                src/regexp/.libs/libre2c_la-ast_to_re.o
__cxa_rethrow                       lib/.libs/libre2c_la-regcomp.o
__cxxabiv1::vector_new(void*, unsigned long, unsigned long, void (*)(void*), void (*)(void*)) src/cfg/.libs/libre2c_la-interfere.o
std::string::get_allocator()const             src/regexp/.libs/libre2c_la-ast_to_re.o
std::string::data()const                       src/regexp/.libs/libre2c_la-ast_to_re.o
std::_Rb_tree_decrement(std::_Rb_tree_node_base*) lib/.libs/libre2c_la-regcomp.o
std::string::size()const                       src/regexp/.libs/libre2c_la-ast_to_re.o
std::string::_Rep::_S_empty_rep()          lib/.libs/libre2c_la-regcomp.o
ld: fatal: symbol referencing errors. No output written to .libs/libre2c.so.0.0.0
gmake[2]: *** [Makefile:2113: libre2c.la] Error 2
gmake[2]: Leaving directory '/export/home/dclarke/foo/re2c-2.1.1'
gmake[1]: *** [Makefile:4518: all-recursive] Error 1
gmake[1]: Leaving directory '/export/home/dclarke/foo/re2c-2.1.1'
gmake: *** [Makefile:1721: all] Error 2

Well gee ... this is a mess. 

Perhaps we don't build the lib? 
skvadrik commented 3 years ago

Hi @blastwave, can you provide information how you configure re2c and how you build it (what commands exactly do you use)?

The goto problem is easy to fix (pushed a fix: https://github.com/skvadrik/re2c/commit/568d4226f7ce8abdc770b7968765e42f407e97f9), although I wonder which initialization the Solaris compiler didn't like (there is a static constant, an uninitialized array and a nested variable in a for-loop; both GCC and Clang consider the code ok).

The link error is weird. By default re2c does not try to build libre2c library (it is an experimental research project), so it should not be built unless you configure with --enable-libs (or -DRE2C_BUILD_LIBS=yes for CMake). That's why I'm asking how exactly you configure and build re2c.

By default re2c tries to build with -O2 -g. This is to provide reasonable defaults for people who build re2c with a simple configure && make && make install (or cmake . && make). It is possible to override default flags on the command line (which I think you did).

Also, by default re2c tries to build with -std=c++98, but I don't see it in you compiler options, so either you patched the build files, or the Solaris compiler does not support this option. What is "strict" C99 and C++ 2011 mode? How is it different from passing an -std option to the compiler?

blastwave commented 3 years ago

OKay, let me go through this as best as I can and provide what details I have.


how you configure re2c ? 

Well firstly we have the environment variables at this time. 
I will put in some blank lines where that makes sense : 

AUTOCONF=/opt/bw/bin/autoconf
AUTOHEADER=/opt/bw/bin/autoheader
AUTOMAKE=/opt/bw/bin/automake
AWK=/opt/bw/bin/gawk
BISON=/opt/bw/bin/bison
CC=/opt/developerstudio12.6/bin/c99

CFLAGS=-m64 -xarch=sparc -xO0 -g -Xc -errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff -xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl -xlibmieee -mc -ftrap=%none -xbuiltin=%none -xunroll=1 -Qy -xdebugformat=dwarf

CONFIG_SHELL=/opt/bw/bin/bash

CPPFLAGS=-I/opt/bw/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE -D_TS_ERRNO -D_X_OPEN_SOURCE=600

CXXFLAGS=-std=c++11 -xO0 -g -dalign -erroff=%none -errtags=yes -ftrap=%none -xcode=pic32 -m64 -xbuiltin=%none -xarch=sparc -xdepend=no -xregs=no%appl -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE -D_TS_ERRNO

CXX=/opt/developerstudio12.6/bin/CC
DISPLAY=localhost:10.0
HOME=/export/home/dclarke
LC_COLLATE=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8

LDFLAGS=-L/opt/bw/lib -R/opt/bw/lib
LD_OPTIONS=-R/opt/bw/lib -L/opt/bw/lib
LD_RUN_PATH=/opt/bw/lib
LIBTOOL_M4=/opt/bw/share/aclocal/libtool.m4
LOGNAME=dclarke
MAIL=/usr/mail/dclarke
MAKE=/opt/bw/bin/gmake
PATH=/opt/bw/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/opt/developerstudio12.6/bin:/sbin:/bin:/usr/bin:/usr/sbin:/opt/bw/bin

PCRE_CONFIG=/opt/bw/bin/pcre-config
PERL=/opt/bw/bin/perl
PWD=/export/home/dclarke/foo/re2c-2.1.1
PYTHON=/opt/bw/bin/python3.7
SSH_TTY=/dev/pts/5
TERM=xterm
TMPDIR=/var/tmp/dclarke
TZ=GMT0
USER=dclarke
_=/usr/xpg4/bin/env
XTERM_LOCALE=en_US.UTF-8
YACC=/opt/bw/bin/bison

Pretty basic stuff but above you see that the compiler here is c99 which is a strictly compliant C compiler. There are CFLAGS that enforce this with -Xc which you can think of as "we really mean we want C99 and we are not joking".

The configuration was thus : 

    ./configure --prefix=/opt/bw \
        --disable-silent-rules --enable-dependency-tracking \
        --enable-debug --enable-libs \
        --enable-shared --enable-static --without-gnu-ld 

That results in this : 

checking for a BSD-compatible install... build-aux/install-sh -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... /opt/bw/bin/gawk
checking whether /opt/bw/bin/gmake sets $(MAKE)... yes
checking whether /opt/bw/bin/gmake supports nested variables... yes
checking whether /opt/bw/bin/gmake supports nested variables... (cached) yes
checking whether /opt/bw/bin/gmake supports the include directive... yes (GNU style)
checking for gcc... /opt/developerstudio12.6/bin/c99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... no
checking whether /opt/developerstudio12.6/bin/c99 accepts -g... yes
checking for /opt/developerstudio12.6/bin/c99 option to accept ISO C89... none needed
checking whether /opt/developerstudio12.6/bin/c99 understands -c and -o together... yes
checking dependency style of /opt/developerstudio12.6/bin/c99... dashXmstdout
checking how to run the C preprocessor... /opt/developerstudio12.6/bin/c99 -E
checking for grep that handles long lines and -e... /opt/bw/bin/grep
checking for egrep... /opt/bw/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether we are using the GNU C++ compiler... no
checking whether /opt/developerstudio12.6/bin/CC accepts -g... yes
checking dependency style of /opt/developerstudio12.6/bin/CC... dashXmstdout
checking for re2/re2.h... no
checking for bison... /opt/bw/bin/bison
checking for gcc... (cached) /opt/developerstudio12.6/bin/c99
checking whether we are using the GNU C compiler... (cached) no
checking whether /opt/developerstudio12.6/bin/c99 accepts -g... (cached) yes
checking for /opt/developerstudio12.6/bin/c99 option to accept ISO C89... (cached) none needed
checking whether /opt/developerstudio12.6/bin/c99 understands -c and -o together... (cached) yes
checking dependency style of /opt/developerstudio12.6/bin/c99... (cached) dashXmstdout
checking whether we are using the GNU C++ compiler... (cached) no
checking whether /opt/developerstudio12.6/bin/CC accepts -g... (cached) yes
checking dependency style of /opt/developerstudio12.6/bin/CC... (cached) dashXmstdout
checking C++ compiler flag -std=c++98... no
checking C++ compiler flag -W... yes
checking C++ compiler flag -Wall... yes
checking C++ compiler flag -Wextra... yes
checking C++ compiler flag -Weffc++... yes
checking C++ compiler flag -pedantic... yes
checking C++ compiler flag -Wformat=2... yes
checking C++ compiler flag -Wredundant-decls... yes
checking C++ compiler flag -Wsuggest-attribute=format... yes
checking C++ compiler flag -Wconversion... yes
checking C++ compiler flag -Wsign-conversion... yes
checking C++ compiler flag -Werror=return-type... yes
checking C++ compiler flag -O2... yes
checking C++ compiler flag -Weverything... yes
checking for stdint.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking for fcntl.h... yes
checking for unistd.h... (cached) yes
checking for io.h... no
checking size of char... 1
checking size of short... 2
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of __int64... 0
checking size of void *... 8
checking size of 0l... 8
checking size of 0ll... 8
checking size of 0i8... 0
checking build system type... sparc-sun-solaris2.10
checking host system type... sparc-sun-solaris2.10
checking how to print strings... printf
checking for a sed that does not truncate output... /opt/bw/bin/sed
checking for fgrep... /opt/bw/bin/grep -F
checking for non-GNU ld... /usr/ccs/bin/ld
checking if the linker (/usr/ccs/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/xpg4/bin/nm -p
checking the name lister (/usr/xpg4/bin/nm -p) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786240
checking how to convert sparc-sun-solaris2.10 file names to sparc-sun-solaris2.10 format... func_convert_file_noop
checking how to convert sparc-sun-solaris2.10 file names to toolchain format... func_convert_file_noop
checking for /usr/ccs/bin/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/xpg4/bin/nm -p output from /opt/developerstudio12.6/bin/c99 object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking for /opt/developerstudio12.6/bin/c99 option to produce PIC... -KPIC -DPIC
checking if /opt/developerstudio12.6/bin/c99 PIC flag -KPIC -DPIC works... yes
checking if /opt/developerstudio12.6/bin/c99 static flag -Bstatic works... yes
checking if /opt/developerstudio12.6/bin/c99 supports -c -o file.o... yes
checking if /opt/developerstudio12.6/bin/c99 supports -c -o file.o... (cached) yes
checking whether the /opt/developerstudio12.6/bin/c99 linker (/usr/ccs/bin/ld -64) supports shared libraries... yes
checking dynamic linker characteristics... solaris2.10 ld.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself... yes
checking whether stripping libraries is possible... no
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... /opt/developerstudio12.6/bin/CC -E
checking whether the /opt/developerstudio12.6/bin/CC linker (/usr/ccs/bin/ld -64) supports shared libraries... yes
checking for /opt/developerstudio12.6/bin/CC option to produce PIC... -KPIC -DPIC
checking if /opt/developerstudio12.6/bin/CC PIC flag -KPIC -DPIC works... yes
checking if /opt/developerstudio12.6/bin/CC static flag -Bstatic works... yes
checking if /opt/developerstudio12.6/bin/CC supports -c -o file.o... yes
checking if /opt/developerstudio12.6/bin/CC supports -c -o file.o... (cached) yes
checking whether the /opt/developerstudio12.6/bin/CC linker (/usr/ccs/bin/ld -64) supports shared libraries... yes
checking dynamic linker characteristics... solaris2.10 ld.so
checking how to hardcode library paths into programs... immediate
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating benchmarks/submatch_nfa/Makefile
config.status: creating benchmarks/submatch_dfa_aot/Makefile
config.status: creating benchmarks/submatch_dfa_jit/Makefile
config.status: creating doc/manpage.rst
config.status: creating doc/help.rst
config.status: creating run_tests.sh
config.status: creating benchmarks/submatch_dfa_aot/run.py
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

That looks pretty sane to me.

The link error is weird?

OKay I guess I should not even try to bother with the libre2c library.

It is an experimental research project??  Is that in a README somewhere? I will go look.

By default re2c tries to build with -O2 -g?  That makes sense.
However I don't have those in my CFLAGS and it looks like configure
did not respect the CFLAGS env var. 

Do I need to specify the CFLAGS also on the command line?

You say "by default re2c tries to build with -std=c++98".  Oh, well in that case I need
to provide different CXXFLAGS and not try C++2011 here.  That is easy. 

Also the "-std" thing looks to be a gnuism for GCC and not for the Oracle studio compiler
tools.  I will re-pull the git repo and start over and also perhaps I may edit the Makefiles
manually to remove the -g -O2 as well as other things I may see. 

When in doubt, try again as they say.

I should let you know that I do see a really large number of warnings
but those don't concern me nearly as much as errors.

Dennis Clarke 

ps: typical warnings that I see are : 

"./src/codegen/code.h", line 685: Warning, refmemnoconstr_aggr: An aggregate class with a reference member lacks a user-defined cons
tructor, which can lead to errors.
"./src/codegen/code.h", line 694: Warning, refmemnoconstr_aggr: An aggregate class with a reference member lacks a user-defined cons
tructor, which can lead to errors.
"./src/parse/parse.h", line 25: Warning, refmemnoconstr_aggr: An aggregate class with a reference member lacks a user-defined constr
uctor, which can lead to errors.
"./src/parse/scanner.h", line 107: Warning, inllargeuse: "re2c::Scanner::get_cinput() const" is too large and will not be expanded i
nline.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/codegen/code.h", line 497: Warning, inllargeuse: "re2c::new_code(re2c::slab_allocator_t<1048576, 8>&, re2c::Code::Kind)" is t
oo large and will not be expanded inline.
"./src/parse/scanner.h", line 107: Warning, inllargeuse: "re2c::Scanner::get_cinput() const" is too large and will not be expanded i
nline.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/codegen/code.h", line 497: Warning, inllargeuse: "re2c::new_code(re2c::slab_allocator_t<1048576, 8>&, re2c::Code::Kind)" is t
oo large and will not be expanded inline.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/parse/scanner.h", line 107: Warning, inllargeuse: "re2c::Scanner::get_cinput() const" is too large and will not be expanded i
nline.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/codegen/code.h", line 497: Warning, inllargeuse: "re2c::new_code(re2c::slab_allocator_t<1048576, 8>&, re2c::Code::Kind)" is t
oo large and will not be expanded inline.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/codegen/code.h", line 450: Warning, inllargeuse: "re2c::new_code(re2c::slab_allocator_t<1048576, 8>&, re2c::Code::Kind)" is t
oo large and will not be expanded inline.
"./src/parse/scanner.h", line 107: Warning, inllargeuse: "re2c::Scanner::get_cinput() const" is too large and will not be expanded i
nline.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/parse/scanner.h", line 107: Warning, inllargeuse: "re2c::Scanner::get_cinput() const" is too large and will not be expanded i
nline.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/parse/scanner.h", line 109: Warning, inllargeuse: "re2c::Scanner::is_eof() const" is too large and will not be expanded inlin
e.
"./src/util/slab_allocator.h", line 73: Warning, inllargeuse: "re2c::slab_allocator_t<1048576, 8>::alloc(unsigned long)" is too larg
e and will not be expanded inline.
"./src/codegen/code.h", line 389:     Where, temwhileinst: While instantiating "re2c::Code* re2c::slab_allocator_t<1048576, 8>::allo
ct<re2c::Code>(unsigned long)".
"./src/codegen/code.h", line 389:     Where, teminstend: Instantiated from non-template code.
"./src/util/string_utils.h", line 13: Warning, inllargeuse: "std::ostringstream::basic_ostringstream(std::_Ios_Openmode)" is too lar
ge and will not be expanded inline.
"../src/parse/lex.re", line 715:     Where, temwhileinst: While instantiating "void re2c::strrreplace<char[3]>(std::string &, const 
std::string &, const char(&)[3])".
"../src/parse/lex.re", line 715:     Where, teminstend: Instantiated from non-template code.
33 Warning(s) detected.
blastwave commented 3 years ago

Strange thing I barely ever took notice of. The Oracle Studio 12.6 tools will accept CCFLAGS and the -std option but only for the C++ compiler and not the C compiler.

blastwave commented 3 years ago

The documentation for the Oracle tools is entirely horrific and says little about selection of a C++ language standard. In fact the only thing I could find was :


The C++ compiler (CC) supports the ISO International Standard for C++,
 ISO IS 14882:2011, Programming Language—C++. The 2011 standard replaced
 the 2003 standard, but the compiler recognizes the new features added
 in C++11 only when the option –std=c++11 is in effect.

The C++ compiler (CC) supports the ISO International Standard for C++,
 ISO IS 14882:2014, Programming Language—C++. The 2014 standard replaced
 the 2011 standard, which in turn replaced the 2003 standard. The
 compiler recognizes the new features added in C++11 only when the
 option –std=c++11 is in effect, and recognizes the new features added
 in C++14 only when the option –std=c++14 is in effect. 

So I will just give this a go with -std=c++11 and see what happens.

Well, everything compiles fine. However the "make check" fails a test : 

.
.
.
FAIL: run_tests.sh
PASS: re2c_test_range
PASS: re2c_test_s_to_n32_unsafe
PASS: re2c_test_ver_to_vernum
PASS: re2c_test_argsubst
============================================================================
Testsuite summary for re2c 2.1.1
============================================================================
# TOTAL: 5
# PASS:  4
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See ./test-suite.log
Please report to re2c-general@lists.sourceforge.net
============================================================================

I can attach the test suite log but all that there is to see is this : 

FAIL       messages/msg_02_i_location_format_gnu.re
FAIL       messages/msg_02.re

.
.
.
-----------------
All:         1593
Ran:         1593
Passed:      1591
Soft errors: 0
Hard errors: 2
-----------------
FAILED
FAIL run_tests.sh (exit status: 1)

Has to be something minor.
skvadrik commented 3 years ago

Thanks for such a detailed answer!

You should configure without --enable-libs:

    ./configure --prefix=/opt/bw \
        --disable-silent-rules --enable-dependency-tracking \
        --enable-debug \
        --without-gnu-ld

OKay I guess I should not even try to bother with the libre2c library.

If you want to build libre2c, we can surely debug the link error, but in that case can you please try configuring with --enable-libs, but without --enable-shared --enable-static, as I'm not sure what is the effect of those options. The library definitely builds on Linux, *BSD, macOS and Windows.

It is an experimental research project?? Is that in a README somewhere? I will go look.

The build instructions page linked from README.md explains that the --enable-libs option stands for "build the experimental libre2c library that provides POSIX regcomp/regexec/regfree interface to re2c."

Brief description of libre2c was on the release notes for re2c-1.2 a while ago: "...The algorithms described in the paper are implemented in an experimental library libre2c. The library is intended as a playground for experiments and research, not a replacement for existing libraries like RE2. Having re2c as a library is convenient for benchmarking, testing and creating bindings to other languages". The paper is linked from the home page: Efficient POSIX Submatch Extraction on NFA.

By default re2c tries to build with -O2 -g? That makes sense. However I don't have those in my CFLAGS and it looks like configure did not respect the CFLAGS env var. Do I need to specify the CFLAGS also on the command line?

Configure did respect your flags, because I can see them in the compiler commands that you posted at the beginning of this thread. On the command line./configure CFLAGS="..." CXXFLAGS="..." also works.

The checking C++ compiler flag -std=c++98... no lines in configure output come from configure.ac, which checks if each compiler flag exists before it tries to use it. So, if your compiler has -std=c++98, re2c will set it; otherwise it won't.

You say "by default re2c tries to build with -std=c++98". Oh, well in that case I need to provide different CXXFLAGS and not try C++2011 here. That is easy.

I'd expect re2c to build with C++11 as well (it does on Linux).

Also the "-std" thing looks to be a gnuism for GCC and not for the Oracle studio compiler tools. I will re-pull the git repo and start over and also perhaps I may edit the Makefiles manually to remove the -g -O2 as well as other things I may see.

As I wrote above, if your compiler doesn't support -std, the build system does not use it. Normally you don't have to patch build files, simply provide the flags you need on the command line (or with env vars as you did).

I should let you know that I do see a really large number of warnings but those don't concern me nearly as much as errors.

This is because configure.ac sets -Weverything and your compiler supports it, that might be an overkill. I use it with Clang sometimes, but it adds a lot of noise.

skvadrik commented 3 years ago

Oh, you've already ran the tests while I was writing the comment. C++11 should be fine, re2c uses C++98 for backward compatibility with old toolchains, but we'll probably switch to C++11 soon, as C++98 causes more trouble than benefit nowadays.

However the "make check" fails a test

If some of the tests fail, there should be a temporary directory (named temp_<timestamp>) with a bunch of files left for the failed tests; in particular, there are diffs. Can you attach those diffs here?

skvadrik commented 3 years ago

Can you attach those diffs here?

Just in case you are not familiar with GitHub interface: if the files are large, it's best to attach them by clicking the gray text "Attach files by dragging & dropping, selecting or pasting them" at the bottom of GutHub comment form instead of pasting in the comment.

blastwave commented 3 years ago

OKay, this is all good progress. Indeed there are some diff files in a directory called test_210330063442 and I will try to attach a tarball. This is what I see :


 alpha $ find test_210330063442/ -type f | xargs wc -l 
      11 test_210330063442/messages/msg_02.re
      11 test_210330063442/messages/msg_02_i_location_format_gnu.re
       1 test_210330063442/messages/msg_02.c.stderr
      51 test_210330063442/messages/msg_02_i_location_format_gnu.orig.c
      51 test_210330063442/messages/msg_02.orig.c
       1 test_210330063442/messages/msg_02_i_location_format_gnu.c
       1 test_210330063442/messages/msg_02_i_location_format_gnu.c.stderr
      54 test_210330063442/messages/msg_02.c.diff
      54 test_210330063442/messages/msg_02_i_location_format_gnu.c.diff
       1 test_210330063442/messages/msg_02.c
     236 total
alpha $ 

oops .. github says they do not support the file type .tar.xz so maybe
I can make a zip file. I have not done a zip file in years.

[test_210330063442.zip](https://github.com/skvadrik/re2c/files/6227092/test_210330063442.zip)

I had to search around to figure out how to make a zip file. No support for tarballs on github?
That feels like a bug. 
skvadrik commented 3 years ago

Ok, the error is the same in both tests:

re2c: error: cannot open file: msg_02.re.inc

It is strange that this file is missing, because there are other .inc files in the tests that don't cause a problem:

$ find test -name '*.inc'
test/messages/nested/msg_02.re.inc
test/include/include003.re.c.inc
test/include/include001.re.c.inc
test/include/include001.re.b.inc
test/include/nested/include002.re.b.inc
test/include/nested/nested/include002.re.bd.inc
test/include/nested/nested/include002.re.be.inc
test/include/nested/nested/include002.re.cd.inc
test/include/nested/nested/include002.re.ce.inc
test/include/nested/include002.re.c.inc
test/include/include003.re.b.inc

Can you confirm that the file test/messages/nested/msg_02.re.inc is not accidentally deleted?

Also, can you rerun ./run_tests.sh -j<N> with different N a few times to see if the results are always the same?

In any case, it's a problem with the test harness, not with re2c itself.

blastwave commented 3 years ago

This is what I see here :


alpha $ which find 
/usr/xpg4/bin/find
alpha $ find test -name '*.inc' | sort 
test/include/include001.re.b.inc
test/include/include001.re.c.inc
test/include/include003.re.b.inc
test/include/include003.re.c.inc
test/include/nested/include002.re.b.inc
test/include/nested/include002.re.c.inc
test/include/nested/nested/include002.re.bd.inc
test/include/nested/nested/include002.re.be.inc
test/include/nested/nested/include002.re.cd.inc
test/include/nested/nested/include002.re.ce.inc
test/messages/nested/msg_02.re.inc
alpha $ 

As you say, this is a test harness issue and not a real test fail. 
I can run the run_tests.sh with various N but really I am fairly happy
with the results here.
blastwave commented 3 years ago

I went ahead and installed the resultant binaries however the man pages look borked :


alpha $ man -M /opt/bw/share/man re2c 
Reformatting page.  Please Wait... done

User Commands                                             RE2C(1)

NAME
     re2c - compile regular expressions to code

SunOS 5.10                Last change:                          1

alpha $ 
alpha $ man -M /opt/bw/share/man re2go
Reformatting page.  Please Wait...nroff: Out of temp file space; line 3258, file /opt/bw/share/man/man1/re2go.1
 done

User Commands                                             RE2C(1)

NAME
alpha $ 

I assure you there is tons of temp file space laying around. 
skvadrik commented 3 years ago

re2c comes with pre-generated man page: https://github.com/skvadrik/re2c/blob/master/bootstrap/doc/re2c.1 (and another one for re2go). Normally the build just copies that file into the build directory and installs it (there is an option to regenerate man pages, but it's only needed if you have changed the documentation and want to rebuild it).

What happens if you do man bootstrap/doc/re2c.1? Does it render correctly, or does it fail with the same (or different) error?

skvadrik commented 3 years ago

Maybe also worth checking with LANG=C man bootstrap/doc/re2c.1.

skvadrik commented 3 years ago

After googling the error, I think that nroff on Solaris might not be able to handle the re2c manpage which is autogenerated from .rst with docutils (rst2man).

blastwave commented 3 years ago

I'm not sure how to work around this manpage issue other than to just manaully copy in the ready-to-read files you provided.

skvadrik commented 3 years ago

What happens if you do man bootstrap/doc/re2c.1? Does it render correctly, or does it fail with the same (or different) error?

Maybe also worth checking with LANG=C man bootstrap/doc/re2c.1

There shouldn't be any need to manually copy pregenerated manpages, that's what the build system does by default. To regenerate them it is necessary to pass --enable-docs configure option, which requires rst2man.py from docutils.

I suspect that the error is happening not in the process of installation of the pregenerated manpages, but in the process of reading them with nroff, because nroff on Solaris cannot handle some of the constructs in the pregenerated manpages (which have also been generated with rst2man.py). But that's just a hypothesis.

skvadrik commented 1 year ago

Closing, as the original issue was resolved. The remaining issue with documentation seems to be due to nroff on Solaris being incompatible with docutils-generated manpage, and there's little we can do here.

blastwave commented 1 year ago

Thank you for looking at this issue. I recall the fun it was to get things working "well enough"(tm).

Sadly I shutdown my last Solaris servers late last year. I think Oracle did a fine job killing it off.

Dennis