Skip to content

Commit

Permalink
[main] use <gnu/lib-names.h> for resolving -lm on linux machines
Browse files Browse the repository at this point in the history
As suggested by @cjwelborn in #16 the above header defines LIBM_SO which is what
we should be using when opening -lm.

Fixes: #17
  • Loading branch information
hexagonal-sun committed Sep 15, 2019
1 parent 9e58a2e commit 6a1f94b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "gc.h"
#include "preprocess.h"

#if defined(BUILD_LINUX)
#include <gnu/lib-names.h>
#endif

extern FILE* cfilein;
extern int cfileparse();

Expand Down Expand Up @@ -77,6 +81,11 @@ static int open_library(char *libname)
char *tmp, *full_library_name;
int ret;

#if defined(BUILD_LINUX)
if (!strcmp(libname, "m"))
libname = LIBM_SO;
#endif

/* First, attempt to open just the library, if it has been fully
* specified. */
if (dlopen(libname, RTLD_NOW | RTLD_GLOBAL))
Expand Down

0 comments on commit 6a1f94b

Please sign in to comment.