Skip to content

Commit

Permalink
Update c++ ldflags for better compatibility. (#91)
Browse files Browse the repository at this point in the history
Seems to work with both clang and gcc on several platforms. But might need more differentiation to cover all variants.

Closes #85.
  • Loading branch information
mittinatten authored Jun 13, 2023
1 parent 2b01039 commit d5898c1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ jobs:
CXX: g++
enable: "--enable-check --enable-json --enable-xml"
deps: "check libjson-c-dev libxml2-dev libxml2-utils libc++-dev libc++abi-dev"
# causes linker errors, what else is needed?
# - CC: clang
# CXX: clang
# enable: "--enable-check --enable-json --enable-xml"
# deps: "check libjson-c-dev libxml2-dev libxml2-utils libc++-dev libc++abi-dev"
- CC: clang
CXX: clang
enable: "--enable-check --enable-json --enable-xml"
deps: "check libjson-c-dev libxml2-dev libxml2-utils libc++-dev libc++abi-dev"
runs-on: ubuntu-latest
steps:
- name: "Check out code"
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AM_LDFLAGS =
AM_CFLAGS =
freesasa_LDADD = -lc++
freesasa_LDADD = -lstdc++
AM_CPPFLAGS = -I$(top_srcdir)/third-party/gemmi/include/

if COND_GCOV
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test_api_SOURCES = test_main.c test_pdb.c test_freesasa.c test_structure.c \

AM_CFLAGS += -I$(top_srcdir)/src -DDATADIR=\"$(top_srcdir)/tests/data/\" -DSHAREDIR=\"$(top_srcdir)/share/\"

test_api_LDADD = ../src/libfreesasa.a
test_api_LDADD = ../src/libfreesasa.a -ldl

if USE_JSON
test_api_SOURCES += test_json.c
Expand Down
6 changes: 6 additions & 0 deletions tests/test_classifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,12 @@ START_TEST(test_backbone)
}
END_TEST


START_TEST(test_memerr)
{
// the mocking of malloc, etc doesn't work with clang
#ifndef __clang__

freesasa_set_verbosity(FREESASA_V_SILENT);
set_fail_after(1);
void *ptr[] = {freesasa_classifier_types_new(),
Expand Down Expand Up @@ -466,9 +470,11 @@ START_TEST(test_memerr)
}
fclose(config);
freesasa_set_verbosity(FREESASA_V_NORMAL);
#endif // __clang__
}
END_TEST


extern TCase *test_classifier_static();

Suite *classifier_suite()
Expand Down
4 changes: 4 additions & 0 deletions tests/test_coord.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ END_TEST

START_TEST(test_memerr)
{
// the mocking of malloc, etc doesn't work with clang
#ifndef __clang__

set_fail_after(0);
static double v[18] = {0, 0, 0, 1, 1, 1, -1, 1, -1, 2, 0, -2, 2, 2, 0, -5, 5, 5};
struct coord_t coord = {.xyz = v, .n = 6, .is_linked = 0};
Expand All @@ -104,6 +107,7 @@ START_TEST(test_memerr)
freesasa_set_verbosity(FREESASA_V_NORMAL);
freesasa_coord_free(coord_dyn);
set_fail_after(0);
#endif // __clang__
}
END_TEST

Expand Down
6 changes: 3 additions & 3 deletions tests/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ realloc(void * ptr, size_t s)
return real_realloc(ptr, s);
}

void*
char*
strdup(const char *s)
{
if (fail_after > 0) {
Expand All @@ -40,7 +40,7 @@ strdup(const char *s)
return NULL;
}
}
void *(*real_strdup)(const char*) = dlsym(RTLD_NEXT, "strdup");
char *(*real_strdup)(const char*) = dlsym(RTLD_NEXT, "strdup");
return real_strdup(s);
}

Expand All @@ -51,7 +51,7 @@ set_fail_after(int limit) {
n_fails = 0;
}

int float_eq(double a, double b, double tolerance)
int float_eq(double a, double b, double tolerance)
{
if (fabs(a-b) < tolerance) return 1;
printf("floats not equal: a = %f, b = %f, diff = %f, tolerance = %f\n",
Expand Down

0 comments on commit d5898c1

Please sign in to comment.