maedoc / libtvb

TVB C library
6 stars 8 forks source link

GCC fsanitize error #145

Closed AbheekG closed 8 years ago

AbheekG commented 8 years ago

Many GCC versions don't support these options. Examples, gcc (Gentoo 4.9.3 p1.5, pie-0.6.4) 4.9.3 and gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4. Either they can be removed in tests, or some instructions can be given on how to support them. Currently travis also works with SANFLAGS= i.e., no sanflags.

Faced the problem after switching from Ubuntu 15.10 to Gentoo.

gcc: error: unrecognized command line option ‘-fsanitize=float-cast-overflow’
gcc: error: unrecognized command line option ‘-fsanitize=undefined’
maedoc commented 8 years ago

ok ok I was thinking of adding some detection logic to the makefile to avoid santizers if compiler doesn't support, but address santizer should be supported in GCC 4.8, undefined behavior in 4.9.

Something like

cc_asan:=$(shell expr `gcc -dumpversion` \>= 4.8)
cc_ubsan:=$(shell expr `gcc -dumpversion` \>= 4.9)

ifeq $(cc_asan) 1
    SANFLAGS += -fsanitize=address
endif

ifeq $(cc_ubsan) 1
    SANFLAGS += -fsanitize=undefined
endif
AbheekG commented 8 years ago

@maedoc Please pull the amendment.

maedoc commented 8 years ago

@abheekg add the float cast flag and I'll merge