Message ID | 1392545101-26953-1-git-send-email-francois.perrad@gadz.org |
---|---|
State | Rejected, archived |
Headers | show |
Hi Francois, On Sun, Feb 16, 2014 at 11:05 AM, Francois Perrad <fperrad@gmail.com> wrote: > fix build for lua-ev > http://autobuild.buildroot.org/results/730/7303fffa6075d02289b6fdb12a1debdf0dd7d6f1//build-end.log > > Signed-off-by: Francois Perrad <francois.perrad@gadz.org> > --- > package/pkg-cmake.mk | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk > index dbe0d97..f0b8e62 100644 > --- a/package/pkg-cmake.mk > +++ b/package/pkg-cmake.mk > @@ -162,8 +162,8 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: > set(CMAKE_SYSTEM_NAME Linux)\n\ > set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ > set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ > - set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ > - set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ > + set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS) -fPIC\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ > + set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS) -fPIC\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ Usually, PIC properties is set at the cmake target level, but this property is driven by the global variable CMAKE_POSITION_INDEPENDENT_CODE (see: http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:POSITION_INDEPENDENT_CODE) I would prefer using this variable, it should not break anything if some projects set this property otherwise. Regards,
2014-02-16 11:51 GMT+01:00 Samuel Martin <s.martin49@gmail.com>: > Hi Francois, > > On Sun, Feb 16, 2014 at 11:05 AM, Francois Perrad <fperrad@gmail.com> wrote: >> fix build for lua-ev >> http://autobuild.buildroot.org/results/730/7303fffa6075d02289b6fdb12a1debdf0dd7d6f1//build-end.log >> >> Signed-off-by: Francois Perrad <francois.perrad@gadz.org> >> --- >> package/pkg-cmake.mk | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk >> index dbe0d97..f0b8e62 100644 >> --- a/package/pkg-cmake.mk >> +++ b/package/pkg-cmake.mk >> @@ -162,8 +162,8 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: >> set(CMAKE_SYSTEM_NAME Linux)\n\ >> set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ >> set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ >> - set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ >> - set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ >> + set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS) -fPIC\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ >> + set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS) -fPIC\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ > > Usually, PIC properties is set at the cmake target level, but this > property is driven by the global variable > CMAKE_POSITION_INDEPENDENT_CODE (see: > http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:POSITION_INDEPENDENT_CODE) > > I would prefer using this variable, it should not break anything if > some projects set this property otherwise. > You are right, my patch is too invasive. BUILD_SHARED_LIBS is correctly set in pkg-cmake.mk by : -DBUILD_SHARED_LIBS=$(if $(BR2_PREFER_STATIC_LIB),OFF,ON) And the CMakeLists.txt of lua-ev contains : ADD_LIBRARY(cmod_ev MODULE lua_ev.c) The CMake documentation (see http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library) said : "For SHARED and MODULE libraries the POSITION_INDEPENDENT_CODE target property is set to TRUE automatically." So, I don't know what to do. François > Regards, > > > -- > Samuel > _______________________________________________ > buildroot mailing list > buildroot@busybox.net > http://lists.busybox.net/mailman/listinfo/buildroot
Hi Francois, On Sun, Feb 16, 2014 at 5:29 PM, François Perrad <francois.perrad@gadz.org> wrote: > 2014-02-16 11:51 GMT+01:00 Samuel Martin <s.martin49@gmail.com>: >> Hi Francois, >> >> On Sun, Feb 16, 2014 at 11:05 AM, Francois Perrad <fperrad@gmail.com> wrote: >>> fix build for lua-ev >>> http://autobuild.buildroot.org/results/730/7303fffa6075d02289b6fdb12a1debdf0dd7d6f1//build-end.log [...] >> >> Usually, PIC properties is set at the cmake target level, but this >> property is driven by the global variable >> CMAKE_POSITION_INDEPENDENT_CODE (see: >> http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:POSITION_INDEPENDENT_CODE) >> >> I would prefer using this variable, it should not break anything if >> some projects set this property otherwise. >> > > You are right, my patch is too invasive. > > BUILD_SHARED_LIBS is correctly set in pkg-cmake.mk by : > -DBUILD_SHARED_LIBS=$(if $(BR2_PREFER_STATIC_LIB),OFF,ON) > > And the CMakeLists.txt of lua-ev contains : > ADD_LIBRARY(cmod_ev MODULE lua_ev.c) > > The CMake documentation (see > http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library) > said : > "For SHARED and MODULE libraries the POSITION_INDEPENDENT_CODE > target property is set to TRUE automatically." > > So, I don't know what to do. Looking carefully at the culprit build config you point above, it appears BR2_PREFER_STATIC_LIB is not set, so in that case it makes sense (to me) to set CMAKE_POSITION_INDEPENDENT_CODE. Because when static libraries are built in such a configuration, they can be used to built shared ones, so it's better if the *.a has been built with -fPIC. So, I tend to think that we could add to the configure options of the cmake infra: -DCMAKE_POSITION_INDEPENDENT_CODE=$(if $(BR2_PREFER_STATIC_LIB),OFF,ON) but this needs more investigations and tests. Regards,
2014-02-16 18:57 GMT+01:00 Samuel Martin <s.martin49@gmail.com>: > Hi Francois, > > On Sun, Feb 16, 2014 at 5:29 PM, François Perrad > <francois.perrad@gadz.org> wrote: >> 2014-02-16 11:51 GMT+01:00 Samuel Martin <s.martin49@gmail.com>: >>> Hi Francois, >>> >>> On Sun, Feb 16, 2014 at 11:05 AM, Francois Perrad <fperrad@gmail.com> wrote: >>>> fix build for lua-ev >>>> http://autobuild.buildroot.org/results/730/7303fffa6075d02289b6fdb12a1debdf0dd7d6f1//build-end.log > [...] >>> >>> Usually, PIC properties is set at the cmake target level, but this >>> property is driven by the global variable >>> CMAKE_POSITION_INDEPENDENT_CODE (see: >>> http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:POSITION_INDEPENDENT_CODE) >>> >>> I would prefer using this variable, it should not break anything if >>> some projects set this property otherwise. >>> >> >> You are right, my patch is too invasive. >> >> BUILD_SHARED_LIBS is correctly set in pkg-cmake.mk by : >> -DBUILD_SHARED_LIBS=$(if $(BR2_PREFER_STATIC_LIB),OFF,ON) >> >> And the CMakeLists.txt of lua-ev contains : >> ADD_LIBRARY(cmod_ev MODULE lua_ev.c) >> >> The CMake documentation (see >> http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library) >> said : >> "For SHARED and MODULE libraries the POSITION_INDEPENDENT_CODE >> target property is set to TRUE automatically." >> >> So, I don't know what to do. > > Looking carefully at the culprit build config you point above, it > appears BR2_PREFER_STATIC_LIB is not set, so in that case it makes > sense (to me) to set CMAKE_POSITION_INDEPENDENT_CODE. > > Because when static libraries are built in such a configuration, they > can be used to built shared ones, so it's better if the *.a has been > built with -fPIC. > > So, I tend to think that we could add to the configure options of the > cmake infra: > -DCMAKE_POSITION_INDEPENDENT_CODE=$(if $(BR2_PREFER_STATIC_LIB),OFF,ON) > > but this needs more investigations and tests. > The issue is solved by http://git.buildroot.net/buildroot/commit/?id=40089283e91fc6daae1aff0346f6821bd2bcab80 François > > Regards, > > -- > Samuel
diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk index dbe0d97..f0b8e62 100644 --- a/package/pkg-cmake.mk +++ b/package/pkg-cmake.mk @@ -162,8 +162,8 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: set(CMAKE_SYSTEM_NAME Linux)\n\ set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ - set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ - set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ + set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS) -fPIC\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ + set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS) -fPIC\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ set(CMAKE_INSTALL_SO_NO_EXE 0)\n\ set(CMAKE_PROGRAM_PATH \"$(HOST_DIR)/usr/bin\")\n\ set(CMAKE_FIND_ROOT_PATH \"$(STAGING_DIR)\")\n\
fix build for lua-ev http://autobuild.buildroot.org/results/730/7303fffa6075d02289b6fdb12a1debdf0dd7d6f1//build-end.log Signed-off-by: Francois Perrad <francois.perrad@gadz.org> --- package/pkg-cmake.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)