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

build error in python-alpine #659

Closed
pepedocs opened this issue Sep 9, 2019 · 7 comments · Fixed by #660
Closed

build error in python-alpine #659

pepedocs opened this issue Sep 9, 2019 · 7 comments · Fixed by #660
Labels
bug Something isn't working build low

Comments

@pepedocs
Copy link

pepedocs commented Sep 9, 2019

I was trying to build htm.core using the python installation instructions. But I encountered some errors below. The build was executed in;

docker image: python-alpine
python: 3.7.4
gcc: 8.3.0

Am I missing something?

[ 17%] Building CXX object src/CMakeFiles/LibrarySource.dir/htm/ntypes/Scalar.cpp.o
[ 18%] Building CXX object src/CMakeFiles/LibrarySource.dir/htm/ntypes/Value.cpp.o
[ 18%] Building CXX object src/CMakeFiles/LibrarySource.dir/htm/os/Directory.cpp.o
[ 19%] Building CXX object src/CMakeFiles/LibrarySource.dir/htm/os/Env.cpp.o
[ 20%] Building CXX object src/CMakeFiles/LibrarySource.dir/htm/os/OS.cpp.o
[ 21%] Building CXX object src/CMakeFiles/LibrarySource.dir/htm/os/OSUnix.cpp.o
/htm.core/src/htm/os/OSUnix.cpp: In static member function 'static std::__cxx11::string htm::OS::getErrorMessageFromErrorCode(int)':
/htm.core/src/htm/os/OSUnix.cpp:87:30: error: invalid conversion from 'int' to 'char*' [-fpermissive]
   char *result = ::strerror_r(errorCode, errorBuffer, sizeof(errorBuffer));
                  ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [src/CMakeFiles/LibrarySource.dir/build.make:417: src/CMakeFiles/LibrarySource.dir/htm/os/OSUnix.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:144: src/CMakeFiles/LibrarySource.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
setup.py: Calling /htm.core/bindings/py/packaging/setup.py

Python version: 3.7.4 (default, Aug 21 2019, 00:19:59)
[GCC 8.3.0]

Traceback (most recent call last):
  File "setup.py", line 53, in <module>
    REPO_DIR = os.path.abspath(os.path.join(PY_BINDINGS, os.pardir, os.pardir, os.pardir))
  File "/usr/local/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/local/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/htm.core/bindings/py/packaging/setup.py", line 312, in <module>
    getExtensionFiles(platform, build_type)
  File "/htm.core/bindings/py/packaging/setup.py", line 204, in getExtensionFiles
    generateExtensions(platform, build_type)
  File "/htm.core/bindings/py/packaging/setup.py", line 297, in generateExtensions
    subprocess.check_call(["cmake", "--build", ".", "--target", "install", "--config", build_type])
  File "/usr/local/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release']' returned non-zero exit status 2.
ERROR: Service 'app' failed to build: The command '/bin/sh -c apk add git && apk add cmake && apk add make && apk add g++                 && git clone https://github.com/htm-community/htm.core                 && cd htm.core && python setup.py install --user --force --prefix=' returned a non-zero code: 1
@breznak breznak added bug Something isn't working build low labels Sep 9, 2019
@breznak
Copy link
Member

breznak commented Sep 9, 2019

/htm.core/src/htm/os/OSUnix.cpp:87:30: error: invalid conversion from 'int' to 'char*' [-fpermissive]
   char *result = ::strerror_r(errorCode, errorBuffer, sizeof(errorBuffer));
                  ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks @pepedocs for reporting the err!
Interesting problem, our CI uses the same compiler (gcc 8.3, python is irrelevant) and does not encounter the error.

The code is part of an (rarely used) IFDEF,

#if defined(__APPLE__) || (defined(NTA_ARCH_64) && defined(NTA_OS_SPARC))
int result = ::strerror_r(errorCode, errorBuffer, sizeof(errorBuffer));
if (result == 0)
errorMessage << errorBuffer;
//normally we run here
#else
char *result = ::strerror_r(errorCode, errorBuffer, sizeof(errorBuffer));
//you ended up here

It'll be good to have our build tested on Alpine, as I think it uses a different libC (?)

  • is Alpine 32bit, or why didn't you fall into the "Linux 64b" (NTA_ARCH_64) bracket?

@dkeeney
Copy link

dkeeney commented Sep 9, 2019

Hmmm, good you pointed this out. I was going to use this function in something I am working on.

The linux man page for strerror_r( ) says:

The XSI-compliant version of strerror_r() is provided if:
(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
Otherwise, the GNU-specific version is provided.

XSI complient version returns an int. The GNU-specific version returns char*.

The std:: lib has strerror( ) but it is not thread-safe. There is stderror_s( ) which returns the int which might be more universal (C++11) and is thread-safe.

        size_t errmsglen = strerrorlen_s(errno) + 1;
        char errmsg[errmsglen]; 
        strerror_s(errmsg, errmsglen, errno);
        std::cout << "Error: " << errmsg << std::endl;

@dkeeney
Copy link

dkeeney commented Sep 9, 2019

I will create a PR to change strerror_r( ) to stderror_s everyplace.

@dkeeney
Copy link

dkeeney commented Sep 9, 2019

Hmmm, strerrorlen_s( ) is not available in MSVC 2017. But the length is never more than 94 characters so a fixed sized buffer of 100 or so would be ok.

@dkeeney
Copy link

dkeeney commented Sep 9, 2019

Oh, strerror_r is used only in OSUnix.cpp in the function getErrorMessageFromErrorCode( ). There is one of these for Windows and one for Unix. BUT getErrorMessageFromErrorCode( ) is never used by anyone.

So, I am just going of get rid of it entirely. :-)

@breznak
Copy link
Member

breznak commented Sep 9, 2019 via email

@dkeeney
Copy link

dkeeney commented Sep 9, 2019

Oh, you beat me to it :)
I will get rid of my PR's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build low
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants