<div dir="ltr">I've pushed a change into 'stage' [1] that I hope to get into 'next' (something isn't working with my ssh authentication).<div><br></div><div>James</div><div><p class="" style="text-align:left"><span style="font-family:monospace,monospace">[1] commit b4e54f9b8c748f78d16e9da055a7e0436d7654ef</span><br><span style="font-family:monospace,monospace">Author: James Bigler <@></span><br><span style="font-family:monospace,monospace">Date:   Tue Jan 6 16:28:05 2015 -0700</span><br><font face="monospace, monospace"><br></font><span style="font-family:monospace,monospace">    FindCUDA: Add relevant CMAKE_{C,CXX}_FLAGS for separable compilation</span><br><span style="font-family:monospace,monospace">    </span><br><span style="font-family:monospace,monospace">    Previously only the CMAKE_{C,CXX}_FLAGS_<CONFIG> flags were inspected</span><br><span style="font-family:monospace,monospace">    for relevant flags when compiling the intermediate link file.  We need</span><br><span style="font-family:monospace,monospace">    to also consider the configuration agnostic flags, CMAKE_{C,CXX}_FLAGS</span><br><span style="font-family:monospace,monospace">    as well.</span><br></p>
















</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 6, 2015 at 4:29 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">Okay, so to conclude:<br>
<br>
Should we make a PR to include your patched code so CMAKE_CXX_FLAGS just works? I think this makes sense, as I would never have thought to do the DEBUG / RELEASE stuff. I can do the PR, unless you want to.<br>
<br>
And, of course, thanks for all your help!<br>
<br>
Irwin<br>
<br>
James Bigler wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
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.<br>
<br>
There is still the issue that I wasn't bringing in the CMAKE_CXX_FLAGS (which is why my patch helped).<br>
<br>
James<br>
<br></span><span class="">
On Tue, Jan 6, 2015 at 1:32 PM, Irwin Zaid <<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.ac.uk</a> <mailto:<a href="mailto:irwin.zaid@physics.ox.ac.uk" target="_blank">irwin.zaid@physics.ox.<u></u>ac.uk</a>>> wrote:<br>
<br>
    Wait, hold on. The -fPIC does get passed to everything if I set<br>
    the build mode to Debug by passing -DCMAKE_BUILD_TYPE=Debug to<br>
    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<br>
    the intermediate linking? Am I meant to always build in Debug mode<br>
    just for that?<br>
<br>
    Irwin<br>
<br>
    Irwin Zaid wrote:<br>
<br>
        I just double-checked. The -fPIC is definitely there for each<br>
        individual<br>
        object file, but not for the *_intermediate_link.o.<br>
<br>
        Irwin<br>
<br>
        James Bigler wrote:<br>
<br>
<br>
            James<br>
<br>
                On Jan 6, 2015, at 11:29 AM, Irwin<br></span>
                Zaid<<a href="mailto:irwin.zaid@physics.ox.ac" target="_blank">irwin.zaid@physics.ox.ac</a>.<u></u>__uk<span class=""><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, so I've gone and put the messages into<br>
                FindCUDA.cmake. I specifically put them right before<br>
                and after the foreach() in<br></span>
                CUDA_LINK_SEPARARABLE___<u></u>COMPILATION_OBJECTS. The<span class=""><br>
                output is the following.<br>
<br>
                Is<br></span>
                "$<$<CONFIG:Debug>:-Xcompiler><u></u>__;$<$<CONFIG:Debug>:-fPIC>"<span class=""><br>
                supposed to be that way? That looks weird.<br>
<br>
            Yeah. That looks right. It means the argument will only be<br>
            run when the build configuration matches DEBUG. This is<br>
            less exciting for Makefiles builds since there is only one<br>
            configuration preset at a time, but for things like Visual<br>
            Studio where you have multiple build configs from a single<br>
            CMake configure this makes a custom command for each<br>
            without having to rely on scripts to dispatch the correct<br>
            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<br>
            comes and goes. Perhaps something is modifying the flags.<br>
            Do the commands with fPIC actually get run with fPIC (use<br>
            make VERBOSE=1)?<br>
<br>
                --<br>
<br>
                going to run COMMAND /usr/local/cuda/bin/nvcc<br>
                -m64;-ccbin;"/usr/bin/cc" -dlink<br></span>
                /home/irwin/Repositories/__<u></u>libdynd/build/CMakeFiles/__<u></u>libdynd.dir/src/dynd/kernels/.<u></u>__/libdynd_generated_<u></u>assignment___kernels.cu.o;/<u></u>home/irwin/__Repositories/<u></u>libdynd/build/__CMakeFiles/<u></u>libdynd.dir/src/__dynd/func/./<u></u>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/./<a href="http://libdynd___generated_ckernel_builder.cu" target="_blank">libdynd___<u></u>generated_ckernel_builder.cu</a><br>
                <<a href="http://generated_ckernel_builder.cu" target="_blank">http://generated_ckernel_<u></u>builder.cu</a>>.__o;/home/irwin/<u></u>Repositories/__libdynd/build/<u></u>CMakeFiles/__libdynd.dir/src/<u></u>dynd/types/./__libdynd_<u></u>generated_dynd___complex.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>float16.cu.o;/__home/irwin/<u></u>Repositories/__libdynd/build/<u></u>CMakeFiles/__libdynd.dir/src/<u></u>dynd/types/./__libdynd_<u></u><a href="http://generated_dynd___float128.cu" target="_blank">generated_dynd___float128.cu</a>.<u></u>o;/home/irwin/__Repositories/<u></u>libdynd/build/__CMakeFiles/<u></u>libdynd.dir/src/__dynd/types/.<u></u>/libdynd___generated_d<br>
<br>
    y<br>
<br>
        nd_int128.cu.o;/home/irwin/__<u></u>Repositories/libdynd/build/__<u></u>CMakeFiles/libdynd.dir/src/d<br>
<br>
                ynd/types/./libdynd_generated_<u></u>__dynd_uint128.cu.o -o<br>
                /home/irwin/Repositories/__<u></u>libdynd/build/CMakeFiles/__<u></u>libdynd.dir/./libdynd___<u></u>intermediate_link.o<span class=""><br>
<br>
                going to run COMMAND /usr/local/cuda/bin/nvcc<br>
                -m64;-ccbin;"/usr/bin/cc" -dlink<br></span>
                /home/irwin/Repositories/__<u></u>libdynd/build/CMakeFiles/__<u></u>libdynd.dir/src/dynd/kernels/.<u></u>__/libdynd_generated_<u></u>assignment___kernels.cu.o;/<u></u>home/irwin/__Repositories/<u></u>libdynd/build/__CMakeFiles/<u></u>libdynd.dir/src/__dynd/func/./<u></u>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/./<a href="http://libdynd___generated_ckernel_builder.cu" target="_blank">libdynd___<u></u>generated_ckernel_builder.cu</a><br>
                <<a href="http://generated_ckernel_builder.cu" target="_blank">http://generated_ckernel_<u></u>builder.cu</a>>.__o;/home/irwin/<u></u>Repositories/__libdynd/build/<u></u>CMakeFiles/__libdynd.dir/src/<u></u>dynd/types/./__libdynd_<u></u>generated_dynd___complex.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>float16.cu.o;/__home/irwin/<u></u>Repositories/__libdynd/build/<u></u>CMakeFiles/__libdynd.dir/src/<u></u>dynd/types/./__libdynd_<u></u><a href="http://generated_dynd___float128.cu" target="_blank">generated_dynd___float128.cu</a>.<u></u>o;/home/irwin/__Repositories/<u></u>libdynd/build/__CMakeFiles/<u></u>libdynd.dir/src/__dynd/types/.<u></u>/libdynd___generated_d<br>
<br>
    y<br>
<br>
        nd_int128.cu.o;/home/irwin/__<u></u>Repositories/libdynd/build/__<u></u>CMakeFiles/libdynd.dir/src/d<br>
<br>
                ynd/types/./libdynd_generated_<u></u>__dynd_uint128.cu.o -o<br>
                /home/irwin/Repositories/__<u></u>libdynd/build/CMakeFiles/__<u></u>libdynd.dir/./libdynd___<u></u>intermediate_link.o<br>
                $<$<CONFIG:Debug>:-Xcompiler>;<u></u>__$<$<CONFIG:Debug>:-fPIC><span class=""><br>
                going to run COMMAND /usr/local/cuda/bin/nvcc<br>
                -m64;-ccbin;"/usr/bin/cc" -dlink<br></span>
                /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_<u></u>libdynd.__dir/func/./test_<u></u>libdynd___generated_test_lift_<u></u>arrfunc.__cu.o<br>
                -o<br>
                /home/irwin/Repositories/__<u></u>libdynd/build/tests/__<u></u>CMakeFiles/test_libdynd.dir/./<u></u>__test_libdynd_intermediate___<u></u>link.o<span class=""><br>
<br>
                going to run COMMAND /usr/local/cuda/bin/nvcc<br>
                -m64;-ccbin;"/usr/bin/cc" -dlink<br></span>
                /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_<u></u>libdynd.__dir/func/./test_<u></u>libdynd___generated_test_lift_<u></u>arrfunc.__cu.o<br>
                -o<br>
                /home/irwin/Repositories/__<u></u>libdynd/build/tests/__<u></u>CMakeFiles/test_libdynd.dir/./<u></u>__test_libdynd_intermediate___<u></u>link.o<br>
                $<$<CONFIG:Debug>:-Xcompiler>;<u></u>__$<$<CONFIG:Debug>:-fPIC><span class=""><br>
<br>
                James Bigler wrote:<br>
<br>
                    I meant putting messages into FindCUDA.cmake itself.<br>
<br>
                    Only certain flags are propagated for the<br>
                    intermediate link file<br>
                    compilation, because I've had a lot of trouble<br>
                    over the years for<br>
                    propagating all the host flags. This set of flags<br>
                    is filtered by the<br></span>
                    function _cuda_get_important_host___<u></u>flags. Right<span class=""><br>
                    now only the<br>
                    CMAKE_CXX_FLAGS_*CONFIG* are being processed. None<br>
                    of the flags in the<br>
                    configuration free variable are passed. That was<br>
                    the "patch" I wanted<br>
                    you to try. Why -fPIC in the configuration<br>
                    specific CMAKE_CXX_FLAGS<br>
                    wasn't working, I'm not sure. The code is there to<br>
                    do it.<br>
<br>
                    On Tue, Jan 6, 2015 at 10:05 AM, Irwin<br></span>
                    Zaid<<a href="mailto:irwin.zaid@physics.ox.ac" target="_blank">irwin.zaid@physics.ox.ac</a>.<u></u>__uk<span class=""><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></span><span class="">
                    Right, when I modify FindCUDA.cmake as you<br>
                    describe everything<br>
                    works. So that's good.<br>
<br>
                    Without doing that, I still don't see<br>
                    CMAKE_CXX_FLAGS_DEBUG<br>
                    propagating its flags to the intermediate link<br>
                    file. Did you mean to<br>
                    put message commands into<br></span>
                    CUDA_LINK_SEPARABLE_____<u></u>COMPILATION_OBJECTS<span class=""><br>
                    itself? When I put them into my main<br>
                    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>>><br></span>
                    <mailto:<a href="mailto:irwin.zaid@physics.ox" target="_blank">irwin.zaid@physics.ox</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>
                    <<a href="http://ac.uk" target="_blank">http://ac.uk</a>><span class=""><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<br>
                    working. We are<br>
                    already adding -fPIC to CMAKE_CXX_FLAGS, should<br>
                    that not be<br>
                    enough? I also tried adding it to both<br>
                    CMAKE_CXX_FLAGS_DEBUG and<br>
                    CMAKE_CXX_FLAGS_RELEASE, with no effect.<br>
<br>
                    Looking into FindCUDA.CMake at<br></span>
                    CUDA_LINK_SEPARABLE_______<u></u>COMPILATION_OBJECTS, I<span class=""><br>
                    find code very<br>
                    similar to what you are describing. Are you saying<br>
                    that in<br>
                    addition to what is below, we need to add what you<br>
                    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></span>
                    foreach(f ${CUDA_NVCC_FLAGS_${config____<u></u>___upper}})<span class=""><br>
                    list(APPEND config_specific_flags<br>
                    $<$<CONFIG:${config}>:${f}>)<br>
                    endforeach()<br>
                    set(important_host_flags)<br></span>
                    _cuda_get_important_host______<u></u>_flags(important_host_flags<br>
                    ${CMAKE_${CUDA_C_OR_CXX}______<u></u>_FLAGS_${config_upper}})<span class=""><br>
                    foreach(f ${important_host_flags})<br>
                    list(APPEND flags<br></span>
                    $<$<CONFIG:${config}>:-______<u></u>Xcompiler><span class=""><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<br>
                    adding it to<br>
                    the _DEBUG or _RELEASE variants. If you could add<br>
                    a few message<br>
                    commands around that might help see what is going<br>
                    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>
<br>
</span></blockquote>
</blockquote></div><br></div>