UG4 / ugcore

The core functionality of UG4. Includes sources, build-scripts, and utility scripts.
https://github.com/UG4/ugcore
Other
36 stars 23 forks source link

GCC 5.4.0 on Ubuntu Xenial Xerus #18

Closed stephanmg closed 3 years ago

stephanmg commented 5 years ago

Static build with target ugshell won't find lib gcc_s on Ubuntu Xenial Xerus to link ugshell.

-- Info: Current options:
-- Info: TARGET:            ugshell (options are: ugshell, libug4, vrl, vrlgrid, libgrid, gridshell, ugplugin, amg, luashell)
-- Info: DIM:               3 (options are: 1, 2, 3, ALL, "1;2", "1;3", "2;3")
-- Info: CPU:               ALL (options are: 1, 2, 3, 4, 5, VAR, ALL, "2;4", "1;3;4" , ...)
-- Info: PRECISION:         double (options are: single, double)
-- Info: STATIC_BUILD:      ON (options are: ON, OFF)
-- Info: DEBUG:             OFF (options are: ON, OFF)
-- Info: DEBUG_LOGS:        OFF (options are: ON, OFF)
-- Info: PARALLEL:          ON (options are: ON, OFF)
-- Info: PCL_DEBUG_BARRIER: OFF (options are: ON, OFF)
-- Info: PROFILER:          None (options are: None, Shiny, Scalasca, Vampir, ScoreP)
-- Info: PROFILE_PCL:       OFF (options are: ON, OFF)
-- Info: CPU_FREQ:          OFF (options are: ON, OFF)
-- Info: PROFILE_BRIDGE:    OFF (options are: ON, OFF)
-- Info: LAPACK:            OFF (options are: ON, OFF)
-- Info: BLAS:              OFF (options are: ON, OFF)
-- Info: INTERNAL_BOOST:    ON (options are: ON, OFF)
-- Info: EMBEDDED_PLUGINS   ON (options are: ON, OFF)
-- Info: COMPILE_INFO       OFF (options are: ON, OFF)
-- Info: USE_LUA2C          OFF (options are: ON, OFF)
-- Info: USE_LUAJIT          (options are: ON, OFF)

Error:

[ 98%] Linking CXX static library ../../lib/libug4_s.a
[ 98%] Built target ug4_s
Scanning dependencies of target ugshell
[ 98%] Building CXX object ugcore/ugbase/ug_shell/CMakeFiles/ugshell.dir/ugshell_main.cpp.o
[ 99%] Building CXX object ugcore/ugbase/ug_shell/CMakeFiles/ugshell.dir/shell.cpp.o
[ 99%] Building CXX object ugcore/ugbase/ug_shell/CMakeFiles/ugshell.dir/main.cpp.o
[ 99%] Building CXX object ugcore/ugbase/ug_shell/CMakeFiles/ugshell.dir/completion.cpp.o
[ 99%] Building CXX object ugcore/ugbase/ug_shell/CMakeFiles/ugshell.dir/externals/linenoise/linenoise.cpp.o
[100%] Linking CXX executable ../../../../bin/ugshell
/usr/bin/ld: cannot find -lgcc_s
../../../../lib/libug4_s.a(loslib.c.o): In function `os_tmpname':
loslib.c:(.text+0x22c): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
ugcore/ugbase/ug_shell/CMakeFiles/ugshell.dir/build.make:204: recipe for target '../bin/ugshell' failed
make[2]: *** [../bin/ugshell] Error 1
CMakeFiles/Makefile2:409: recipe for target 'ugcore/ugbase/ug_shell/CMakeFiles/ugshell.dir/all' failed
make[1]: *** [ugcore/ugbase/ug_shell/CMakeFiles/ugshell.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
ERROR: Job failed: exit code 1

Runningldconfig -p | grep libgcc shows libgcc_s.so.1 thus I tried to symlink to the library by: ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/libgcc_s.so No success here...

Secondly Static build with target libug4 results in another error, see below:

-- Info: Current options:
-- Info: TARGET:            libug4 (options are: ugshell, libug4, vrl, vrlgrid, libgrid, gridshell, ugplugin, amg, luashell)
-- Info: DIM:               3 (options are: 1, 2, 3, ALL, "1;2", "1;3", "2;3")
-- Info: CPU:               ALL (options are: 1, 2, 3, 4, 5, VAR, ALL, "2;4", "1;3;4" , ...)
-- Info: PRECISION:         double (options are: single, double)
-- Info: STATIC_BUILD:      ON (options are: ON, OFF)
-- Info: DEBUG:             OFF (options are: ON, OFF)
-- Info: DEBUG_LOGS:        OFF (options are: ON, OFF)
-- Info: PARALLEL:          ON (options are: ON, OFF)
-- Info: PCL_DEBUG_BARRIER: OFF (options are: ON, OFF)
-- Info: PROFILER:          None (options are: None, Shiny, Scalasca, Vampir, ScoreP)
-- Info: PROFILE_PCL:       OFF (options are: ON, OFF)
-- Info: CPU_FREQ:          OFF (options are: ON, OFF)
-- Info: PROFILE_BRIDGE:    OFF (options are: ON, OFF)
-- Info: LAPACK:            OFF (options are: ON, OFF)
-- Info: BLAS:              OFF (options are: ON, OFF)
-- Info: INTERNAL_BOOST:    ON (options are: ON, OFF)
-- Info: EMBEDDED_PLUGINS   ON (options are: ON, OFF)
-- Info: COMPILE_INFO       OFF (options are: ON, OFF)
-- Info: USE_LUA2C          OFF (options are: ON, OFF)
-- Info: USE_LUAJIT          (options are: ON, OFF)

Error:

[ 57%] Building C object ugcore/CMakeFiles/ug4_s.dir/ugbase/bindings/lua/externals/lua/lzio.c.o
[ 57%] Building CXX object ugcore/CMakeFiles/ug4_s.dir/ugbase/bindings/lua/lua_user_data.cpp.o
In file included from /builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/global_function.h:39:0,
                 from /builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/registry.h:45,
                 from /builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/bridge/bridge.h:39,
                 from /builds/stephanmg/mdfe/ug4/ugcore/ugbase/bindings/lua/lua_user_data.cpp:38:
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/parameter_stack.h: In instantiation of 'static T ug::bridge::ParameterStack::ToType<T>::to(const ug::bridge::ParameterStack*, int) [with T = ug::LuaFunctionHandle]':
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/parameter_stack.h:476:65:   required from 'T ug::bridge::ParameterStack::to(int) const [with T = ug::LuaFunctionHandle]'
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/param_to_type_value_list.h:76:58:   required from 'ug::bridge::ParameterStackToTypeValueList<TTypeList, index>::ParameterStackToTypeValueList(const ug::bridge::ParameterStack&) [with TTypeList = ug::TypeList<ug::LuaFunctionHandle, int, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType>; int index = 0]'
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/class.h:444:53:   required from 'static void* ug::bridge::ConstructorProxy<TClass, TMethod>::create(const ug::bridge::ParameterStack&) [with TClass = ug::LuaUserFunction<double, 3, double>; TMethod = void (*)(ug::LuaFunctionHandle, int)]'
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/class.h:821:32:   required from 'ug::bridge::ExportedClass<TClass>& ug::bridge::ExportedClass<TClass>::add_constructor(std::string, std::string, std::string, std::string) [with TFunc = void (*)(ug::LuaFunctionHandle, int); TClass = ug::LuaUserFunction<double, 3, double>; std::string = std::basic_string<char>]'
/builds/stephanmg/mdfe/ug4/ugcore/ugbase/bindings/lua/lua_user_data.cpp:185:3:   required from 'static void ug::bridge::LuaUserData::Functionality::Dimension(ug::bridge::Registry&, std::string) [with int dim = 3; std::string = std::basic_string<char>]'
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/bridge/util.h:61:46:   required from 'void ug::bridge::RegisterDimensionDependent(ug::bridge::Registry&, std::string) [with Functionality = ug::bridge::LuaUserData::Functionality; std::string = std::basic_string<char>]'
/builds/stephanmg/mdfe/ug4/ugcore/ugbase/bindings/lua/lua_user_data.cpp:287:52:   required from here
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/parameter_stack.h:470:151: error: '___UG_REGISTRY_ERROR___FUNCTION_OR_METHOD_PARAMETERS_RESTRICTED_to__NATIVE_TYPES__or__POINTER_resp_SMARTPOINTER_to_registered_types____' is not a member of 'ug::LuaFunctionHandle'
     return T::___UG_REGISTRY_ERROR___FUNCTION_OR_METHOD_PARAMETERS_RESTRICTED_to__NATIVE_TYPES__or__POINTER_resp_SMARTPOINTER_to_registered_types____();
                                                                                                                                                       ^
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/parameter_stack.h: In instantiation of 'static void ug::bridge::ParameterInfo::PushType<T>::push(ug::bridge::ParameterInfo*) [with T = ug::LuaFunctionHandle]':
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/parameter_stack.h:164:49:   required from 'void ug::bridge::ParameterInfo::push_type() [with T = ug::LuaFunctionHandle]'
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/param_to_type_value_list.h:94:3:   required from 'static void ug::bridge::CreateParameterInfo<TTypeList>::create(ug::bridge::ParameterInfo&) [with TTypeList = ug::TypeList<ug::LuaFunctionHandle, int, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType, ug::EmptyType>]'
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/class.h:390:55:   required from 'void ug::bridge::ExportedConstructor::create_parameter_stack() [with TFunc = void (*)(ug::LuaFunctionHandle, int)]'
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/class.h:826:4:   required from 'ug::bridge::ExportedClass<TClass>& ug::bridge::ExportedClass<TClass>::add_constructor(std::string, std::string, std::string, std::string) [with TFunc = void (*)(ug::LuaFunctionHandle, int); TClass = ug::LuaUserFunction<double, 3, double>; std::string = std::basic_string<char>]'
/builds/stephanmg/mdfe/ug4/ugcore/ugbase/bindings/lua/lua_user_data.cpp:185:3:   required from 'static void ug::bridge::LuaUserData::Functionality::Dimension(ug::bridge::Registry&, std::string) [with int dim = 3; std::string = std::basic_string<char>]'
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/bridge/util.h:61:46:   required from 'void ug::bridge::RegisterDimensionDependent(ug::bridge::Registry&, std::string) [with Functionality = ug::bridge::LuaUserData::Functionality; std::string = std::basic_string<char>]'
/builds/stephanmg/mdfe/ug4/ugcore/ugbase/bindings/lua/lua_user_data.cpp:287:52:   required from here
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/parameter_stack.h:157:144: error: '___UG_REGISTRY_ERROR___FUNCTION_OR_METHOD_PARAMETERS_RESTRICTED_to__NATIVE_TYPES__or__POINTER_resp_SMARTPOINTER_to_registered_types____' is not a member of 'ug::LuaFunctionHandle'
     T::___UG_REGISTRY_ERROR___FUNCTION_OR_METHOD_PARAMETERS_RESTRICTED_to__NATIVE_TYPES__or__POINTER_resp_SMARTPOINTER_to_registered_types____();
                                                                                                                                                ^
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/parameter_stack.h: In static member function 'static T ug::bridge::ParameterStack::ToType<T>::to(const ug::bridge::ParameterStack*, int) [with T = ug::LuaFunctionHandle]':
/builds/stephanmg/mdfe/ug4/ugcore/cmake/../../ugcore/ugbase/registry/parameter_stack.h:471:3: warning: control reaches end of non-void function [-Wreturn-type]
   }};
   ^
ugcore/CMakeFiles/ug4_s.dir/build.make:5726: recipe for target 'ugcore/CMakeFiles/ug4_s.dir/ugbase/bindings/lua/lua_user_data.cpp.o' failed
make[2]: *** [ugcore/CMakeFiles/ug4_s.dir/ugbase/bindings/lua/lua_user_data.cpp.o] Error 1
CMakeFiles/Makefile2:90: recipe for target 'ugcore/CMakeFiles/ug4_s.dir/all' failed
make[1]: *** [ugcore/CMakeFiles/ug4_s.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
ERROR: Job failed: exit code 1

Building with STATIC_BUILD=OFF succeeds for targets shell and VRL. (Didn't try libug4).

Any hints how to fix this?

Best wishes, SG

mlampe commented 5 years ago

The CMake-generated link line for ugshell with -DSTATIC_BUILD=ON looks like this:

/opt/rh/devtoolset-8/root/usr/bin/g++ -std=c++98 -Wall -Wno-multichar -O3 -DNDEBUG -funroll-loops -ftree-vectorize CMakeFiles/ugshell.dir/ugshell_main.cpp.o CMakeFiles/ugshell.dir/shell.cpp.o CMakeFiles/ugshell.dir/main.cpp.o CMakeFiles/ugshell.dir/completion.cpp.o CMakeFiles/ugshell.dir/externals/linenoise/linenoise.cpp.o -o ../../../../bin/ugshell -L/home/lampe/ug4/ugcore/cmake/../../lib -rdynamic -Wl,-Bdynamic -llapack -lblas -Wl,-Bstatic -ldl -Wl,-Bdynamic /usr/local/openmpi-gcc-1.8.8/lib/libmpi_cxx.so /usr/local/openmpi-gcc-1.8.8/lib/libmpi.so ../../../../lib/libug4_s.a -lsuperlu ../../../../lib/libparmetis.a ../../../../lib/libmetis.a -llapack -lblas -Wl,-Bstatic -ldl -Wl,-Bdynamic /usr/local/openmpi-gcc-1.8.8/lib/libmpi_cxx.so /usr/local/openmpi-gcc-1.8.8/lib/libmpi.so -Wl,-Bstatic -lm -Wl,-rpath,/home/lampe/ug4/ugcore/cmake/../../lib:/usr/local/openmpi-gcc-1.8.8/lib

The final -Wl,-Bstatic makes the linker look for libgcc_s.a -- which doesn't exist (at all).

stephanmg commented 5 years ago

@mlampe this is true. I'm sorry I did not post my make VERBOSE=1 output. I'm not sure, should I hunt for the CMakeLists.txt to address this? Yes, this gives me the same thing:

... Wl,-Bstatic -lm -Wl,-rpath,/home/sgrein/Code/git/ug4/ugcore/cmake/../../lib:/usr/local/openmpi-gcc-1.8.8/lib ...

mlampe commented 5 years ago

What is the intended effect of -DSTATIC_BUILD=ON at link time? Without knowing this, it's hard to fix anything.

stephanmg commented 5 years ago

What is the intended effect of -DSTATIC_BUILD=ON at link time? Without knowing this, it's hard to fix anything.

I agree. For my purposes I can switch to -DSTATIC_BUILD=OFF and this works well... but for the general audience maybe it might be interesting how to fix this and compile statically e.g. on a cluster.

mlampe commented 5 years ago

Do you want a fully static binary or a binary that statically links ug4, when you say -DSTATIC_BUILD=ON ?

stephanmg commented 5 years ago

Actually I'm fine with my -DSTATIC_BUILD=OFF UG 4 version. I just assumed that when making use of the -DSTATIC_BUILD=ON option the build should succeed in the end.

mlampe commented 5 years ago

It works on systems than can only do static linking. It's systems that can do both and default to dynamic linking for which cmake produces this non-working link line.

stephanmg commented 5 years ago

@mlampe: Thanks for clarification. I assume one would want a fully static binary. But I guess one should wait for other opinions on this issue. To this end... should this issue remain open?

mlampe commented 3 years ago

STATIC_BUILD=ON now links all parts of ug4+plugins statically into one binary with system libraries following the system's default.