Re: [waffle] [PATCH 10/33] cmake: build with fPIC when possible

2014-07-17 Thread Jose Fonseca

On 17/07/14 05:22, Chad Versace wrote:

On 07/15/2014 07:44 AM, Jose Fonseca wrote:

On 07/07/14 18:28, Emil Velikov wrote:

Some of our third_party libraries may be build without it thus we'll
fail at
link tim.

Signed-off-by: Emil Velikov 
---
   cmake/Modules/WaffleDefineCompilerFlags.cmake | 2 ++
   1 file changed, 2 insertions(+)

diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake
b/cmake/Modules/WaffleDefineCompilerFlags.cmake
index 4d149c8..96a7a10 100644
--- a/cmake/Modules/WaffleDefineCompilerFlags.cmake
+++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
@@ -50,6 +50,8 @@ if(waffle_on_linux)
   waffle_add_c_flag("-Werror=missing-prototypes"
WERROR_MISSING_PROTOTYPES)
   endif()

+waffle_add_c_flag("-fPIC" WITH_FPIC)
+
   waffle_check_thread_local_storage()

   if(waffle_has_tls)



Another way of fixing this is doing like in Apitrace:

-
https://urldefense.proofpoint.com/v1/url?u=https://github.com/apitrace/apitrace/blob/master/cmak/ConvenienceLibrary.cmake&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0A&m=ZXpgDERxJiJIOkLmgiWyvvdFCmOYeacV64waeZuyXto%3D%0A&s=550e80c43976ae6b7767b413f4500e1b92725f7ba8c82a921682e3c4913c2e04


-
https://urldefense.proofpoint.com/v1/url?u=https://github.com/apitrace/apitrace/commit/c56b9acc6abcae465b916f6ebafa3a282d1f36fc&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0A&m=ZXpgDERxJiJIOkLmgiWyvvdFCmOYeacV64waeZuyXto%3D%0A&s=3c0e0609776f678836fd6485f5485299a1ae228c092c74abfbecdbb67c434c5d


This gives more control.  For example, unlike a blanket -FPIC flag,
executables won't be needlessly compiled with FPIC.


Jose, your add_convenience_library() function may be unneeded. See the
manpage quote below.


You're right.  Setting POSITION_INDEPENDENT_CODE property is much 
simpler/cleaner.  (Though I still find it convienent to have a 
add_convenience_library for the time being, as there are a bunch of such 
libraries in apitrace so it provides me a centralized place for these 
tweaks):



https://github.com/apitrace/apitrace/commit/d99553937cc53b82965421da1ca950c17f16a324

Jose

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 10/33] cmake: build with fPIC when possible

2014-07-16 Thread Chad Versace
On 07/15/2014 07:44 AM, Jose Fonseca wrote:
> On 07/07/14 18:28, Emil Velikov wrote:
>> Some of our third_party libraries may be build without it thus we'll
>> fail at
>> link tim.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>   cmake/Modules/WaffleDefineCompilerFlags.cmake | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake
>> b/cmake/Modules/WaffleDefineCompilerFlags.cmake
>> index 4d149c8..96a7a10 100644
>> --- a/cmake/Modules/WaffleDefineCompilerFlags.cmake
>> +++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
>> @@ -50,6 +50,8 @@ if(waffle_on_linux)
>>   waffle_add_c_flag("-Werror=missing-prototypes"
>> WERROR_MISSING_PROTOTYPES)
>>   endif()
>>
>> +waffle_add_c_flag("-fPIC" WITH_FPIC)
>> +
>>   waffle_check_thread_local_storage()
>>
>>   if(waffle_has_tls)
>>
> 
> Another way of fixing this is doing like in Apitrace:
> 
> -
> https://github.com/apitrace/apitrace/blob/master/cmak/ConvenienceLibrary.cmake
> 
> 
> -
> https://github.com/apitrace/apitrace/commit/c56b9acc6abcae465b916f6ebafa3a282d1f36fc
> 
> 
> This gives more control.  For example, unlike a blanket -FPIC flag,
> executables won't be needlessly compiled with FPIC.

Jose, your add_convenience_library() function may be unneeded. See the
manpage quote below.

Emil, did you intend to compile *everything*, including executables,
with PIC?

On master, Waffle is already building shared libraries with PIC. I
verified it with:

$ ninja clean
$ ninja -v libwaffle-1.so | grep -e '-o libwaffle'
... cc  -fPIC ... -o lib/libwaffle-1.so.0.3.90 ...

CMake's default behavior is to build shared libraries with PIC. From
man://cmake(1) :

>set_target_properties
>...
>POSITION_INDEPENDENT_CODE
>   Whether to create a position-independent target
> 
>   The  POSITION_INDEPENDENT_CODE property determines whether posi‐
>   tion independent executables or shared libraries  will  be  cre‐
>   ated.   This  property  is true by default for SHARED and MODULE
>   library targets and false otherwise.  This property is  initial‐
>   ized  by  the  value  of  the  variable  CMAKE_POSITION_INDEPEN‐
>   DENT_CODE if it is set when a target is created.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 10/33] cmake: build with fPIC when possible

2014-07-15 Thread Jose Fonseca

On 07/07/14 18:28, Emil Velikov wrote:

Some of our third_party libraries may be build without it thus we'll fail at
link tim.

Signed-off-by: Emil Velikov 
---
  cmake/Modules/WaffleDefineCompilerFlags.cmake | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake 
b/cmake/Modules/WaffleDefineCompilerFlags.cmake
index 4d149c8..96a7a10 100644
--- a/cmake/Modules/WaffleDefineCompilerFlags.cmake
+++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
@@ -50,6 +50,8 @@ if(waffle_on_linux)
  waffle_add_c_flag("-Werror=missing-prototypes" WERROR_MISSING_PROTOTYPES)
  endif()

+waffle_add_c_flag("-fPIC" WITH_FPIC)
+
  waffle_check_thread_local_storage()

  if(waffle_has_tls)



Another way of fixing this is doing like in Apitrace:

- 
https://github.com/apitrace/apitrace/blob/master/cmak/ConvenienceLibrary.cmake 



- 
https://github.com/apitrace/apitrace/commit/c56b9acc6abcae465b916f6ebafa3a282d1f36fc


This gives more control.  For example, unlike a blanket -FPIC flag, 
executables won't be needlessly compiled with FPIC.


Jose


___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 10/33] cmake: build with fPIC when possible

2014-07-07 Thread Brian Paul

On 07/07/2014 11:28 AM, Emil Velikov wrote:

Some of our third_party libraries may be build without it thus we'll fail at
link tim.


time.




Signed-off-by: Emil Velikov 
---
  cmake/Modules/WaffleDefineCompilerFlags.cmake | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake 
b/cmake/Modules/WaffleDefineCompilerFlags.cmake
index 4d149c8..96a7a10 100644
--- a/cmake/Modules/WaffleDefineCompilerFlags.cmake
+++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
@@ -50,6 +50,8 @@ if(waffle_on_linux)
  waffle_add_c_flag("-Werror=missing-prototypes" WERROR_MISSING_PROTOTYPES)
  endif()

+waffle_add_c_flag("-fPIC" WITH_FPIC)
+
  waffle_check_thread_local_storage()

  if(waffle_has_tls)



___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 10/33] cmake: build with fPIC when possible

2014-07-07 Thread Emil Velikov
Some of our third_party libraries may be build without it thus we'll fail at
link tim.

Signed-off-by: Emil Velikov 
---
 cmake/Modules/WaffleDefineCompilerFlags.cmake | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake 
b/cmake/Modules/WaffleDefineCompilerFlags.cmake
index 4d149c8..96a7a10 100644
--- a/cmake/Modules/WaffleDefineCompilerFlags.cmake
+++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
@@ -50,6 +50,8 @@ if(waffle_on_linux)
 waffle_add_c_flag("-Werror=missing-prototypes" WERROR_MISSING_PROTOTYPES)
 endif()
 
+waffle_add_c_flag("-fPIC" WITH_FPIC)
+
 waffle_check_thread_local_storage()
 
 if(waffle_has_tls)
-- 
2.0.0

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle