Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX Portability issues #12

Open
Siesh1oo opened this issue Mar 10, 2014 · 0 comments
Open

OSX Portability issues #12

Siesh1oo opened this issue Mar 10, 2014 · 0 comments

Comments

@Siesh1oo
Copy link


  Hi, this patch resolves some build issues on OSX 10.9 (earlier versions are probably affected, too).

   - Apple's gcc and clang cannot build '-static' binaries (crt0.o missing).
   - The '-soname' option is '-dylib_install_name' on OSX.
   - For linking, the order of options matters.
   - minisat::memUsedPeak() definition was not matching the declaration.
   - unused arguments need to be (void) casted to avoid a compiler warning.

 Sincerely,
 H.

diff --git a/Makefile b/Makefile
index ceb9d77..7782c85 100644
--- a/Makefile
+++ b/Makefile
@@ -62,6 +62,14 @@ SORELEASE?=.0#   Declare empty to leave out from library file name.
 MINISAT_CXXFLAGS = -I. -D __STDC_LIMIT_MACROS -D __STDC_FORMAT_MACROS -Wall -Wno-parentheses -Wextra
 MINISAT_LDFLAGS  = -Wall -lz

+ifeq (Darwin,$(findstring Darwin,$(shell uname)))
+   SHARED_LDFLAGS += -shared -Wl,-dylib_install_name,$(MINISAT_DLIB).$(SOMAJOR)
+   RELEASE_LDFLAGS +=
+else
+   SHARED_LDFLAGS += -shared -Wl,-soname,$(MINISAT_DLIB).$(SOMAJOR)
+   RELEASE_LDFLAGS += -static
+endif
+
 ECHO=@echo
 ifeq ($(VERB),)
 VERB=@
@@ -96,9 +104,9 @@ $(BUILD_DIR)/dynamic/%.o:            MINISAT_CXXFLAGS +=$(MINISAT_REL) $(MINISAT_FPIC)

 ## Build-type Link-flags:
 $(BUILD_DIR)/profile/bin/$(MINISAT):       MINISAT_LDFLAGS += -pg
-$(BUILD_DIR)/release/bin/$(MINISAT):       MINISAT_LDFLAGS += --static $(MINISAT_RELSYM)
+$(BUILD_DIR)/release/bin/$(MINISAT):       MINISAT_LDFLAGS += $(RELEASE_LDFLAGS) $(MINISAT_RELSYM)
 $(BUILD_DIR)/profile/bin/$(MINISAT_CORE):  MINISAT_LDFLAGS += -pg
-$(BUILD_DIR)/release/bin/$(MINISAT_CORE):  MINISAT_LDFLAGS += --static $(MINISAT_RELSYM)
+$(BUILD_DIR)/release/bin/$(MINISAT_CORE):  MINISAT_LDFLAGS += $(RELEASE_LDFLAGS) $(MINISAT_RELSYM)

 ## Executable dependencies
 $(BUILD_DIR)/release/bin/$(MINISAT):       $(BUILD_DIR)/release/minisat/simp/Main.o $(BUILD_DIR)/release/lib/$(MINISAT_SLIB)
@@ -162,7 +170,7 @@ $(BUILD_DIR)/dynamic/lib/$(MINISAT_DLIB).$(SOMAJOR).$(SOMINOR)$(SORELEASE)\
  $(BUILD_DIR)/dynamic/lib/$(MINISAT_DLIB):
    $(ECHO) Linking Shared Library: $@
    $(VERB) mkdir -p $(dir $@)
-   $(VERB) $(CXX) $(MINISAT_LDFLAGS) $(LDFLAGS) -o $@ -shared -Wl,-soname,$(MINISAT_DLIB).$(SOMAJOR) $^
+   $(VERB) $(CXX) $^ $(SHARED_LDFLAGS) $(MINISAT_LDFLAGS) $(LDFLAGS) -o $@
    $(VERB) ln -sf $(MINISAT_DLIB).$(SOMAJOR).$(SOMINOR)$(SORELEASE) $(BUILD_DIR)/dynamic/lib/$(MINISAT_DLIB).$(SOMAJOR)
    $(VERB) ln -sf $(MINISAT_DLIB).$(SOMAJOR) $(BUILD_DIR)/dynamic/lib/$(MINISAT_DLIB)

diff --git a/minisat/utils/System.cc b/minisat/utils/System.cc
index 21aa4ff..b353bec 100644
--- a/minisat/utils/System.cc
+++ b/minisat/utils/System.cc
@@ -77,7 +77,7 @@ double Minisat::memUsed() {
     struct rusage ru;
     getrusage(RUSAGE_SELF, &ru);
     return (double)ru.ru_maxrss / 1024; }
-double Minisat::memUsedPeak() { return memUsed(); }
+double Minisat::memUsedPeak(bool strictlyPeak) { (void) strictlyPeak; return memUsed(); }


 #elif defined(__APPLE__)
@@ -87,11 +87,11 @@ double Minisat::memUsed() {
     malloc_statistics_t t;
     malloc_zone_statistics(NULL, &t);
     return (double)t.max_size_in_use / (1024*1024); }
-double Minisat::memUsedPeak() { return memUsed(); }
+double Minisat::memUsedPeak(bool strictlyPeak) { (void) strictlyPeak; return memUsed(); }

 #else
 double Minisat::memUsed()     { return 0; }
-double Minisat::memUsedPeak() { return 0; }
+double Minisat::memUsedPeak(bool strictlyPeak) { (void) strictlyPeak; return 0; }
 #endif


cmears added a commit to cmears/minisat that referenced this issue Jan 13, 2017
conp-solutions referenced this issue in conp-solutions/mergesat Apr 6, 2018
Resolution for bug tracker issues #1, #4, #9, #10, #12, #13, #14.
teeaychem added a commit to teeaychem/minisat that referenced this issue Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant