<div dir="ltr">Right, if you don't specify the CMAKE_BUILD_TYPE you are only getting the CMAKE_CXX_FLAGS and none of the build type specific flags such as CMAKE_CXX_FLAGS_DEBUG.<div><br></div><div>There is still the issue that I wasn't bringing in the CMAKE_CXX_FLAGS (which is why my patch helped).</div><div><br></div><div>James</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 6, 2015 at 1:32 PM, Irwin Zaid <span dir="ltr"><<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Wait, hold on. The -fPIC does get passed to everything if I set the build mode to Debug by passing -DCMAKE_BUILD_TYPE=Debug to CMake. Is that what I should be doing? (Sorry about that, if yes.)<br>
<br>
If that's the case, what is the correct way to get -fPIC passed to the intermediate linking? Am I meant to always build in Debug mode just for that?<br>
<br>
Irwin<br>
<br>
Irwin Zaid wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
I just double-checked. The -fPIC is definitely there for each individual<br>
object file, but not for the *_intermediate_link.o.<br>
<br>
Irwin<br>
<br>
James Bigler wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
James<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
On Jan 6, 2015, at 11:29 AM, Irwin Zaid<<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.ac.<u></u>uk</a>>   wrote:<br>
<br></span><span class="">
Okay, so I've gone and put the messages into FindCUDA.cmake. I specifically put them right before and after the foreach() in CUDA_LINK_SEPARARABLE_<u></u>COMPILATION_OBJECTS. The output is the following.<br>
<br>
Is "$<$<CONFIG:Debug>:-Xcompiler><u></u>;$<$<CONFIG:Debug>:-fPIC>" supposed to be that way? That looks weird.<br>
<br>
</span></blockquote><span class="">
Yeah. That looks right. It means the argument will only be run when the build configuration matches DEBUG. This is less exciting for Makefiles builds since there is only one configuration preset at a time, but for things like Visual Studio where you have multiple build configs from a single CMake configure this makes a custom command for each without having to rely on scripts to dispatch the correct command (that's how the rest of FindCUDA works by the way).<br>
<br>
As far as the rest of these, I'm concerned the fPIC flag comes and goes. Perhaps something is modifying the flags. Do the commands with fPIC actually get run with fPIC (use make VERBOSE=1)?<br>
<br>
</span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
--<br>
<br>
going to run COMMAND /usr/local/cuda/bin/nvcc -m64;-ccbin;"/usr/bin/cc" -dlink /home/irwin/Repositories/<u></u>libdynd/build/CMakeFiles/<u></u>libdynd.dir/src/dynd/kernels/.<u></u>/libdynd_generated_assignment_<u></u>kernels.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/func/./libdynd_generated_<u></u>arithmetic.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/func/./libdynd_generated_<u></u>elwise.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/kernels/./libdynd_<u></u><a href="http://generated_ckernel_builder.cu" target="_blank">generated_ckernel_builder.cu</a>.<u></u>o;/home/irwin/Repositories/<u></u>libdynd/build/CMakeFiles/<u></u>libdynd.dir/src/dynd/types/./<u></u>libdynd_generated_dynd_<u></u>complex.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/types/./libdynd_<u></u>generated_dynd_float16.cu.o;/<u></u>home/irwin/Repositories/<u></u>libdynd/build/CMakeFiles/<u></u>libdynd.dir/src/dynd/types/./<u></u>libdynd_generated_dynd_<u></u>float128.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/types/./libdynd_<u></u>generated_d<br>
</blockquote></div></div></blockquote></blockquote><div class="HOEnZb"><div class="h5">
y<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
nd_int128.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/d<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
ynd/types/./libdynd_generated_<u></u>dynd_uint128.cu.o -o /home/irwin/Repositories/<u></u>libdynd/build/CMakeFiles/<u></u>libdynd.dir/./libdynd_<u></u>intermediate_link.o<br>
<br>
going to run COMMAND /usr/local/cuda/bin/nvcc -m64;-ccbin;"/usr/bin/cc" -dlink /home/irwin/Repositories/<u></u>libdynd/build/CMakeFiles/<u></u>libdynd.dir/src/dynd/kernels/.<u></u>/libdynd_generated_assignment_<u></u>kernels.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/func/./libdynd_generated_<u></u>arithmetic.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/func/./libdynd_generated_<u></u>elwise.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/kernels/./libdynd_<u></u><a href="http://generated_ckernel_builder.cu" target="_blank">generated_ckernel_builder.cu</a>.<u></u>o;/home/irwin/Repositories/<u></u>libdynd/build/CMakeFiles/<u></u>libdynd.dir/src/dynd/types/./<u></u>libdynd_generated_dynd_<u></u>complex.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/types/./libdynd_<u></u>generated_dynd_float16.cu.o;/<u></u>home/irwin/Repositories/<u></u>libdynd/build/CMakeFiles/<u></u>libdynd.dir/src/dynd/types/./<u></u>libdynd_generated_dynd_<u></u>float128.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/<u></u>dynd/types/./libdynd_<u></u>generated_d<br>
</blockquote></blockquote></blockquote>
y<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
nd_int128.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>CMakeFiles/libdynd.dir/src/d<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
ynd/types/./libdynd_generated_<u></u>dynd_uint128.cu.o -o /home/irwin/Repositories/<u></u>libdynd/build/CMakeFiles/<u></u>libdynd.dir/./libdynd_<u></u>intermediate_link.o $<$<CONFIG:Debug>:-Xcompiler>;<u></u>$<$<CONFIG:Debug>:-fPIC><br>
going to run COMMAND /usr/local/cuda/bin/nvcc -m64;-ccbin;"/usr/bin/cc" -dlink /home/irwin/Repositories/<u></u>libdynd/build/tests/<u></u>CMakeFiles/test_libdynd.dir/<u></u>func/./test_libdynd_generated_<u></u>test_apply.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>tests/CMakeFiles/test_libdynd.<u></u>dir/func/./test_libdynd_<u></u>generated_test_lift_arrfunc.<u></u>cu.o -o /home/irwin/Repositories/<u></u>libdynd/build/tests/<u></u>CMakeFiles/test_libdynd.dir/./<u></u>test_libdynd_intermediate_<u></u>link.o<br>
<br>
going to run COMMAND /usr/local/cuda/bin/nvcc -m64;-ccbin;"/usr/bin/cc" -dlink /home/irwin/Repositories/<u></u>libdynd/build/tests/<u></u>CMakeFiles/test_libdynd.dir/<u></u>func/./test_libdynd_generated_<u></u>test_apply.cu.o;/home/irwin/<u></u>Repositories/libdynd/build/<u></u>tests/CMakeFiles/test_libdynd.<u></u>dir/func/./test_libdynd_<u></u>generated_test_lift_arrfunc.<u></u>cu.o -o /home/irwin/Repositories/<u></u>libdynd/build/tests/<u></u>CMakeFiles/test_libdynd.dir/./<u></u>test_libdynd_intermediate_<u></u>link.o $<$<CONFIG:Debug>:-Xcompiler>;<u></u>$<$<CONFIG:Debug>:-fPIC><br>
<br>
James Bigler wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I meant putting messages into FindCUDA.cmake itself.<br>
<br>
Only certain flags are propagated for the intermediate link file<br>
compilation, because I've had a lot of trouble over the years for<br>
propagating all the host flags. This set of flags is filtered by the<br>
function _cuda_get_important_host_<u></u>flags. Right now only the<br>
CMAKE_CXX_FLAGS_*CONFIG* are being processed. None of the flags in the<br>
configuration free variable are passed. That was the "patch" I wanted<br>
you to try. Why -fPIC in the configuration specific CMAKE_CXX_FLAGS<br>
wasn't working, I'm not sure. The code is there to do it.<br>
<br>
On Tue, Jan 6, 2015 at 10:05 AM, Irwin Zaid<<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.ac.<u></u>uk</a><br>
<mailto:<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.<u></u>ac.uk</a>>>   wrote:<br>
<br>
     Right, when I modify FindCUDA.cmake as you describe everything<br>
     works. So that's good.<br>
<br>
     Without doing that, I still don't see CMAKE_CXX_FLAGS_DEBUG<br>
     propagating its flags to the intermediate link file. Did you mean to<br>
     put message commands into CUDA_LINK_SEPARABLE___<u></u>COMPILATION_OBJECTS<br>
     itself? When I put them into my main CMakeLists.txt, nothing is<br>
     printed for ${nvcc_flags} or the other variables.<br>
<br>
     James Bigler wrote:<br>
<br>
         On Tue, Jan 6, 2015 at 8:54 AM, Irwin Zaid<br>
         <<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.ac.uk</a><br>
         <mailto:<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.<u></u>ac.uk</a>><br>
         <mailto:<a href="mailto:irwin.zaid@physics.ox." target="_blank">irwin.zaid@physics.ox.</a><u></u>__<a href="http://ac.uk" target="_blank">ac.uk</a><br>
         <mailto:<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.<u></u>ac.uk</a>>>>   wrote:<br>
<br>
         Okay, an update on this.<br>
<br>
         2) This is trickier and, unfortunately, still not working. We are<br>
         already adding -fPIC to CMAKE_CXX_FLAGS, should that not be<br>
         enough? I also tried adding it to both CMAKE_CXX_FLAGS_DEBUG and<br>
         CMAKE_CXX_FLAGS_RELEASE, with no effect.<br>
<br>
         Looking into FindCUDA.CMake at<br>
         CUDA_LINK_SEPARABLE_____<u></u>COMPILATION_OBJECTS, I find code very<br>
         similar to what you are describing. Are you saying that in<br>
         addition to what is below, we need to add what you proposed? This<br>
         is what I see.<br>
<br>
         --<br>
<br>
<br>
         It can be put here (before this foreach).<br>
<br>
         foreach(config ${CUDA_configuration_types})<br>
         string(TOUPPER ${config} config_upper)<br>
         # Add config specific flags<br>
         foreach(f ${CUDA_NVCC_FLAGS_${config____<u></u>_upper}})<br>
         list(APPEND config_specific_flags $<$<CONFIG:${config}>:${f}>)<br>
         endforeach()<br>
         set(important_host_flags)<br>
         _cuda_get_important_host_____<u></u>flags(important_host_flags<br>
         ${CMAKE_${CUDA_C_OR_CXX}_____<u></u>FLAGS_${config_upper}})<br>
         foreach(f ${important_host_flags})<br>
         list(APPEND flags $<$<CONFIG:${config}>:-____<u></u>Xcompiler><br>
         $<$<CONFIG:${config}>:${f}>)<br>
         endforeach()<br>
         endforeach()<br>
<br>
<br>
         Or it can be put here (or after the foreach).<br>
<br>
         I'm concerned that the flag didn't show up after adding it to<br>
         the _DEBUG or _RELEASE variants. If you could add a few message<br>
         commands around that might help see what is going on. The flag<br>
         needs to be propagated.<br>
<br>
         You could sprinkle a few commands like this:<br>
         message("going to run COMMAND ${CUDA_NVCC_EXECUTABLE}<br>
         ${nvcc_flags} -dlink ${object_files} -o ${output_file}<br>
         ${flags}")<br>
<br>
<br>
<br>
</blockquote></blockquote></blockquote></blockquote>
</div></div></blockquote></div><br></div>