google/pik

Build with VS is completely broken

pps83 opened this issue · 7 comments

pps83 commented

It used to build a few months ago (if anybody was willing to fiddle with cmake), but current pik isn't even close to building on VS.

Can you please provide proper instructions on how to build pik on VS, or better, simply add proper VS projects instead of dealing with cmake mess.

During cmake step it fails with these messages:

-- Configuring done
CMake Error at CMakeLists.txt:26 (add_library):
  Cannot find source file:

    bit_buffer.h

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error at CMakeLists.txt:169 (add_executable):
  Cannot find source file:

    png2y4m.cc

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error at CMakeLists.txt:169 (add_executable):
  Cannot find source file:

    y4m2png.cc

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


-- Generating done
-- Build files have been written to: C:/pik0/msvc

C:\pik0\msvc>

When I try to build I get these errors:

1>c:\pik0\af_stats.h(52): error C2665: 'pik::N_NONE::sqrt': none of the 2 overloads could convert all the argument types
1>  c:\pik0\simd/scalar.h(500): note: could be 'pik::N_NONE::scalar<double> pik::N_NONE::sqrt(const pik::N_NONE::scalar<double>)'
1>  c:\pik0\simd/scalar.h(497): note: or       'pik::N_NONE::scalar<float> pik::N_NONE::sqrt(const pik::N_NONE::scalar<float>)'
1>  c:\pik0\af_stats.h(52): note: while trying to match the argument list '(double)'

and most importantly pikcommon doesn't contain any files. It's empty:

image

when I fix these (by fixing broken cmake files), I get these:

1>c:\pik0\simd/x86_sse4.h(1356): error C2912: explicit specialization 'pik::N_SSE4::vec_sse4<float,4> pik::N_SSE4::load<float>(pik::N_SSE4::Desc<T,4,Target>,const float *__restrict )' is not a specialization of a function template
1>          with
1>          [
1>              T=float,
1>              Target=pik::SSE4
1>          ]

Can you provide proper build tools?

Hi, thanks for reaching out. We don't officially support CMake nor MSVC, but occasionally we can help make them work :)

I just created native MSVC build files. Getting it to build required fairly widespread changes to the code, which I'll push soon.

pps83 commented

Thanks Jan,
I can help with VS specific changes to make it build. You can find builtin clz/ctz emulation in my gist.

I also made PR to butteraugi which should be relevant here as well.

Thank you offering to help! I've added ifdefs inside the bits.h functions, code changes are not a problem and we avoid the unsigned long vs long-long workarounds.

Interesting that MSVC needs a cast of nullptr - seemed to work OK on 15.3 (2017). Which version needs the cast? (From your PR I'm assuming 2015?)

Update: build succeeds but round-trip test fails. I need to integrate my code changes into our dev environment, ensure they're OK, then investigate further.

pps83 commented

Interesting that MSVC needs a cast of nullptr - seemed to work OK on 15.3 (2017). Which version needs the cast? (From your PR I'm assuming 2015?)

Correct, I'm using 2015.

Also, IMO it's better to completely avoid ctzl/clzl variants and use ll versions for 64 bit numbers. My gitst adds overload for c++ to make them work with 64-bit numbers even though unsigned long is always 32-bit on windows.

Made some progress: updated CMakeLists.txt and pushed the code changes + MSVC build files,
but there are two issues remaining:

  1. guetzli directory has butteraugli_comparator/entropy_encode, which also exist in pik/.
    Suggest renaming those to guetzli_* because MSBuild can't handle name collisions despite multiple directories.

  2. Either remove all calls to SIMD_NONE specializations in simd/dispatch.h, or add another
    source file that #defines SIMD_ENABLE 0 and #includes af_edge_preserving_filter.cc.

After fixing these, I saw our round-trip test fails when built with MSVC.
Unfortunately I am unable to investigate further; we only support building on Linux at the moment.

pps83 commented

After pulling latest I get these errors:

1>C:\pik\pik.cc(208): error C2672: 'pik::dispatch::Run': no matching overloaded function found
1>C:\pik\pik.cc(208): error C2893: Failed to specialize function template 'unknown-type pik::dispatch::Run(const int,Func &&,Args &&...)'
...
1>C:\pik\quantizer.cc(892): error C2075: 'pik::AddDequantizeDC::<lambda_1a348e291128beae9ad5acdbaf349894>::mul_dc': array initialization requires a brace-enclosed initializer list

I think the first one is the af_edge_preserving_filter issue mentioned above (2).
For the second, it seems to work with the free MSVC 2017 (15.3). Is updating an option?