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 build error: "/etc/os-release" does not exist #172

Closed
maparent opened this issue May 7, 2019 · 17 comments
Closed

OSX build error: "/etc/os-release" does not exist #172

maparent opened this issue May 7, 2019 · 17 comments

Comments

@maparent
Copy link
Contributor

maparent commented May 7, 2019

cmake/Summary.cmake:8 reads /etc/os-release which does not exist on OSX, making the cmake fail. Simply commenting out the lines introduced in 264a199 allows the build to succeed.
With apologies for the noise in #98, I did not read the error messages properly.

@ngeiswei
Copy link
Member

ngeiswei commented May 8, 2019

Could you create a PR for it as I don't know if we have an OSX maintainer? Thanks!

@maparent
Copy link
Contributor Author

maparent commented May 8, 2019

I will do it over the weekend, and try to build atomspace properly as well. I found many issues with install_location in both code bases. No promises for long-term maintanance, but I am confident I can make it work short-term.

@linas
Copy link
Member

linas commented May 9, 2019

Here's a quick hack:

diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake
index fe4a99727..a2cbf2789 100644
--- a/cmake/Summary.cmake
+++ b/cmake/Summary.cmake
@@ -4,9 +4,13 @@ set(summary_willnotbuild "")
 set(summary_willnotbuild_d "")
 set(max_name_length "0")
 
-file(READ "/etc/os-release" _OSR)
-string(REGEX MATCH "PRETTY_NAME=\"([a-xA-Z0-9 \\.,:;!@%#/()]*)" _BARF ${_OSR})
-set(OS_RELEASE ${CMAKE_MATCH_1})
+if (APPLE)
+       set(OS_RELEASE "APPLE Unknown release")
+else (APPLE)
+       file(READ "/etc/os-release" _OSR)
+       string(REGEX MATCH "PRETTY_NAME=\"([a-xA-Z0-9 \\.,:;!@%#/()]*)" _BARF ${_OSR})
+       set(OS_RELEASE ${CMAKE_MATCH_1})
+endif (APPLE)
 
 macro(summary_add name description test)
   string(LENGTH ${name} namelength)

does it work?

@maparent
Copy link
Contributor Author

maparent commented May 9, 2019

That problem is solved by the following:

@@ -4,10 +4,6 @@ set(summary_willnotbuild "")
 set(summary_willnotbuild_d "")
 set(max_name_length "0")

-file(READ "/etc/os-release" _OSR)
-string(REGEX MATCH "PRETTY_NAME=\"([a-xA-Z0-9 \\.,:;!@%#/()]*)" _BARF ${_OSR})
-set(OS_RELEASE ${CMAKE_MATCH_1})
-
 macro(summary_add name description test)
   string(LENGTH ${name} namelength)
   if (${namelength} GREATER ${max_name_length})
@@ -45,7 +41,7 @@ endmacro(summary_show_part)

 macro(summary_show)
   message("")
-  message("Building for ${OS_RELEASE}")
+  message("Building for ${CMAKE_SYSTEM_NAME}")
   summary_show_part(summary_willbuild summary_willbuild_d
       "The following components will be built:")
   summary_show_part(summary_willnotbuild summary_willnotbuild_d

I'm now moving on to RPATH issues. I have atomspace built and passing most tests, except 27 tests using libsmob.so. But some of my cmake code is not portable yet. I will keep you posted.

@linas
Copy link
Member

linas commented May 9, 2019

But ${CMAKE_SYSTEM_NAME} doesn't actually report the release... it only reports the OS name (e.g. Linux, for me)

@maparent
Copy link
Contributor Author

maparent commented May 9, 2019

added CMAKE_SYSTEM_VERSION

@maparent
Copy link
Contributor Author

maparent commented May 9, 2019

I've set CMAKE_BUILD_WITH_INSTALL_RPATH to TRUE. I could put that in if (APPLE) if you want; but I think it may be a good idea in general. Open to discuss.
But I clearly needed this so libraries would load.

@linas
Copy link
Member

linas commented May 9, 2019

For me, CMAKE_SYSTEM_VERSION returns the OS kernel version, not the actual system version. For me, it returns 4.8.0-0.bpo.2-amd64 which is just some rando kernel; whereas /etc/os-release is Debian GNU/Linux 9 (stretch)

@maparent
Copy link
Contributor Author

maparent commented May 9, 2019

fair enough. I'll hide it in an IF.

@linas
Copy link
Member

linas commented May 9, 2019

I suspect that setting CMAKE_BUILD_WITH_INSTALL_RPATH to TRUE will break unit tests.

We've had repeated arguments about the unit tests, there is a strong contingent that wants to be able to run them without installing first. Which kind-of makes sense - you don't want to install something that's broken.

I see this:

# RPATH handling (see https://cmake.org/Wiki/CMake_RPATH_handling)
# Note: RPATH only supported under Linux!
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/opencog")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

and so I am guessing that for OSX, the path "${CMAKE_INSTALL_PREFIX}/lib/opencog" is somehow wrong.

@maparent
Copy link
Contributor Author

maparent commented May 9, 2019

Actually, with the base configuration as is, I have the bare name of the library (which fails.) I tried using INSTALL_NAME, and cmake kept trying to use the build path. RPath works fine on Mac (contra the cmake page quoted.)

@maparent
Copy link
Contributor Author

maparent commented May 9, 2019

I had to move the calculation in the macro, because CMAKE_SYSTEM_NAME is not yet defined at the point where you calculated OS_VERSION.

@linas
Copy link
Member

linas commented May 9, 2019

The CI tests are failing: 23% tests passed, 10 tests failed out of 13 -- https://circleci.com/gh/opencog/cogutil/253 which is almost surely due to the rpath change.

@maparent
Copy link
Contributor Author

maparent commented May 9, 2019

Thank you, I just made it conditional to APPLE.

@linas
Copy link
Member

linas commented May 9, 2019

Thank you, I just made it conditional to APPLE.

Hang on, the tests are running now, and cogutil passed, lets see if atomspace passes.

@maparent
Copy link
Contributor Author

maparent commented May 9, 2019

PS: this works with gcc-9 in homebrew, not with clang.

@linas
Copy link
Member

linas commented May 9, 2019

this works with gcc-9 in homebrew, not with clang.

I'll take patches for that, or an error message that prints "clang won't work".

@linas linas closed this as completed May 9, 2019
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

3 participants