Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: add reproducible build option #1370

Merged
merged 8 commits into from
Jul 29, 2024

Conversation

clementperon
Copy link
Collaborator

@clementperon clementperon commented Apr 20, 2024

In order to validate that the clang-format doesn't mess our code we could check if the build is reproductible or not.
#1257

This has been tested with MacOS / Clang.
LibPacket++.a is properly rebuilt from scratch and shasum are equal.

Needs more test under Linux and Windows

@egecetin egecetin changed the base branch from master to dev April 20, 2024 10:43
CMakeLists.txt Outdated Show resolved Hide resolved
@clementperon clementperon force-pushed the reproductible branch 3 times, most recently from 7ad5b92 to dcba746 Compare April 20, 2024 15:48
@seladb
Copy link
Owner

seladb commented Apr 22, 2024

@clementperon I can help with testing. How do you want me to test on Windows/Linux?

@clementperon
Copy link
Collaborator Author

clementperon commented Apr 22, 2024

@clementperon I can help with testing. How do you want me to test on Windows/Linux?

Build a first time with the option ON and compute the SHA1 of the libPacket++.a and libPcap++.a

Remove the binaries folder, rebuild again with the option ON, recompute again and check if SHA1 are equal or not.

@seladb
Copy link
Owner

seladb commented Apr 22, 2024

@clementperon I can help with testing. How do you want me to test on Windows/Linux?

Build a first time with the option ON and compute the SHA1 of the libPacket++.a and libPcap++.a

Remove the binaries folder, rebuild again with the option ON, recompute again and check if SHA1 are equal or not.

If you build the same thing twice on the same code, shouldn't the binary be similar? 🤔

@clementperon
Copy link
Collaborator Author

@clementperon I can help with testing. How do you want me to test on Windows/Linux?

Build a first time with the option ON and compute the SHA1 of the libPacket++.a and libPcap++.a
Remove the binaries folder, rebuild again with the option ON, recompute again and check if SHA1 are equal or not.

If you build the same thing twice on the same code, shouldn't the binary be similar? 🤔

No you could have some build information like date, time, path, hostname that are host specific.

@seladb
Copy link
Owner

seladb commented Apr 22, 2024

@clementperon I'll test it on Windows and Linux and keep you posted

@seladb
Copy link
Owner

seladb commented Apr 23, 2024

@clementperon I ran it on MSVC 2019 and it seems the hash in both runs is different.
In the first run, the hashes are:

SHA1 hash of build\Packet++\Debug\Packet++.lib:
06c03d73804c07d7b0fb1a887e3240ed10f20530

SHA1 hash of build\Pcap++\Debug\Pcap++.lib:
eb25bf6aac27d731bc354660154f07f62890851b

In the second run, the hashes are:

SHA1 hash of build\Packet++\Debug\Packet++.lib:
9ded5b8efaad45f0411d5c3842e2b3452acf9daa

SHA1 hash of build\Pcap++\Debug\Pcap++.lib:
79691e1657305120d0137665b8463fc97d3eabd0

Here is the complete output:

First run:

D:\seladb\PcapPlusPlus>cmake -DPCAP_ROOT=D:\seladb\npcap-sdk -DPCAPPP_BUILD_REPRODUCIBLE=ON -S . -B build
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19045.
-- The CXX compiler identification is MSVC 19.25.28611.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is MSVC 19.25.28611.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test PCAP_LINKS_SOLO
-- Performing Test PCAP_LINKS_SOLO - Success
-- Looking for pcap_set_immediate_mode
-- Looking for pcap_set_immediate_mode - found
-- Looking for pcap_setdirection
-- Looking for pcap_setdirection - found
-- Looking for pcap_lib_version
-- Looking for pcap_lib_version - found
-- Found PCAP: D:/seladb/npcap-sdk/Lib/x64/wpcap.lib
-- Found Packet: D:/seladb/npcap-sdk/Lib/x64/Packet.lib
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Found Git: D:/Apps/Git/cmd/git.exe (found version "2.23.0.windows.1")
-- Building from commit:4423cd24 on branch:reproductible
-- Looking for backtrace
-- Looking for backtrace - not found
-- Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR)
-- Backtrace not found or not supported!
-- Building Example from PcapPlusPlus project
-- Configuring done
-- Generating done
-- Build files have been written to: D:/seladb/PcapPlusPlus/build

D:\seladb\PcapPlusPlus>cmake --build build -j
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule D:/seladb/PcapPlusPlus/3rdParty/hash-library/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/3rdParty/LightPcapNg/CMakeLists.txt
  md5.cpp
  light_advanced.c
  light_alloc.c
  light_compression.c
  light_internal.c
  light_io.c
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(91,56): warning C4133: '=': incompatible types - from 'light_file' to 'FILE *' [D:\seladb\PcapPlusPlus\build\3
rdParty\LightPcapNg\light_pcapng.vcxproj]
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(117,34): warning C4133: 'function': incompatible types - from 'FILE *' to 'light_file' [D:\seladb\PcapPlusPlus
\build\3rdParty\LightPcapNg\light_pcapng.vcxproj]
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(118,32): warning C4133: 'function': incompatible types - from 'FILE *' to 'light_file' [D:\seladb\PcapPlusPlus
\build\3rdParty\LightPcapNg\light_pcapng.vcxproj]
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(132,34): warning C4133: 'function': incompatible types - from 'FILE *' to 'light_file' [D:\seladb\PcapPlusPlus
\build\3rdParty\LightPcapNg\light_pcapng.vcxproj]
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(155,31): warning C4133: 'function': incompatible types - from 'FILE *' to 'light_file' [D:\seladb\PcapPlusPlus
\build\3rdParty\LightPcapNg\light_pcapng.vcxproj]
  light_manipulate.c
  light_null_compression.c
  light_option.c
  light_pcapng_cont.c
  light_pcapng_ext.c
  light_pcapng.c
  light_platform.c
  light_zstd_compression.c
  Generating Code...
  hash-library.vcxproj -> D:\seladb\PcapPlusPlus\build\3rdParty\hash-library\hash-library.dir\Debug\hash-library.lib
  light_pcapng.vcxproj -> D:\seladb\PcapPlusPlus\build\3rdParty\LightPcapNg\light_pcapng.dir\Debug\light_pcapng.lib
  Building Custom Rule D:/seladb/PcapPlusPlus/Common++/CMakeLists.txt
  GeneralUtils.cpp
  IpAddress.cpp
  Building Custom Rule D:/seladb/PcapPlusPlus/3rdParty/MemPlumber/MemPlumber/CMakeLists.txt
  IpUtils.cpp
  memplumber.cpp
  Logger.cpp
  MacAddress.cpp
  memplumber.vcxproj -> D:\seladb\PcapPlusPlus\build\3rdParty\MemPlumber\MemPlumber\Debug\memplumber.lib
  OUILookup.cpp
  PcapPlusPlusVersion.cpp
  SystemUtils.cpp
  TablePrinter.cpp
  Generating Code...
  Common++.vcxproj -> D:\seladb\PcapPlusPlus\build\Common++\Debug\Common++.lib
  Building Custom Rule D:/seladb/PcapPlusPlus/Packet++/CMakeLists.txt
  ArpLayer.cpp
  BgpLayer.cpp
  CotpLayer.cpp
  DhcpLayer.cpp
  DhcpV6Layer.cpp
  DnsLayer.cpp
  DnsResource.cpp
  DnsResourceData.cpp
  EthDot3Layer.cpp
  EthLayer.cpp
  FtpLayer.cpp
  GreLayer.cpp
  GtpLayer.cpp
  HttpLayer.cpp
  IcmpLayer.cpp
  IcmpV6Layer.cpp
  IgmpLayer.cpp
  IPReassembly.cpp
  IPSecLayer.cpp
  IPv4Layer.cpp
  Generating Code...
  Compiling...
  IPv6Extensions.cpp
  IPv6Layer.cpp
  Layer.cpp
  LLCLayer.cpp
  MplsLayer.cpp
  NdpLayer.cpp
  NflogLayer.cpp
  NtpLayer.cpp
  NullLoopbackLayer.cpp
  Packet.cpp
  PacketTrailerLayer.cpp
  PacketUtils.cpp
  PayloadLayer.cpp
  PPPoELayer.cpp
  RadiusLayer.cpp
  RawPacket.cpp
  S7CommLayer.cpp
  SdpLayer.cpp
  SingleCommandTextProtocol.cpp
  SipLayer.cpp
  Generating Code...
  Compiling...
  Sll2Layer.cpp
  SllLayer.cpp
  SmtpLayer.cpp
  SomeIpLayer.cpp
  SomeIpSdLayer.cpp
  SSHLayer.cpp
  SSLCommon.cpp
  SSLHandshake.cpp
  SSLLayer.cpp
  StpLayer.cpp
  TcpLayer.cpp
  TcpReassembly.cpp
  TelnetLayer.cpp
  TextBasedProtocol.cpp
  TLVData.cpp
  TpktLayer.cpp
  UdpLayer.cpp
  VlanLayer.cpp
  VrrpLayer.cpp
  VxlanLayer.cpp
  Generating Code...
  Compiling...
  WakeOnLanLayer.cpp
  Generating Code...
  Packet++.vcxproj -> D:\seladb\PcapPlusPlus\build\Packet++\Debug\Packet++.lib
  Building Custom Rule D:/seladb/PcapPlusPlus/Pcap++/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Tests/Packet++Test/CMakeLists.txt
  NetworkUtils.cpp
  main.cpp
  PcapFileDevice.cpp
  BgpTests.cpp
  PcapDevice.cpp
  PcapFilter.cpp
  CotpTests.cpp
  PcapLiveDevice.cpp
  DhcpTests.cpp
  PcapLiveDeviceList.cpp
  DhcpV6Tests.cpp
  PcapRemoteDevice.cpp
  DnsTests.cpp
  PcapRemoteDeviceList.cpp
  RawSocketDevice.cpp
  WinPcapLiveDevice.cpp
  EthAndArpTests.cpp
  Generating Code...
  FtpTests.cpp
  Pcap++.vcxproj -> D:\seladb\PcapPlusPlus\build\Pcap++\Debug\Pcap++.lib
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/PcapSplitter/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/PcapSearch/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/ArpSpoofing/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/IcmpFileTransfer/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/DNSResolver/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/IPFragUtil/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/HttpAnalyzer/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/DnsSpoofing/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/IPDefragUtil/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/IcmpFileTransfer/CMakeLists.txt
  GreTests.cpp
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/SSLAnalyzer/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/PcapPlusPlus-benchmark/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Tests/Pcap++Test/CMakeLists.txt
  main.cpp
  main.cpp
  GtpTests.cpp
  main.cpp
  main.cpp
  main.cpp
  Common.cpp
  main.cpp
  main.cpp
  Common.cpp
  main.cpp
  TestUtils.cpp
  benchmark.cpp
  main.cpp
  IcmpFileTransfer-pitcher.cpp
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/TcpReassembly/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/TLSFingerprinting/CMakeLists.txt
  HttpTests.cpp
  IcmpFileTransfer-catcher.cpp
  main.cpp
  Generating Code...
  main.cpp
  Generating Code...
D:\seladb\PcapPlusPlus\Tests\Pcap++Test\main.cpp(308,17): warning C4193: #pragma warning(pop): no matching '#pragma warning(push)' [D:\seladb\PcapPlusPlus\build\Tests\Pcap++Test\Pca
p++Test.vcxproj]
  main.cpp
  DpdkTests.cpp
  IcmpTests.cpp
  FileTests.cpp
  ArpSpoofing.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\ArpSpoofing.exe
  DNSResolver.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\DNSResolver.exe
  PcapSearch.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\PcapSearch.exe
  IPDefragUtil.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\IPDefragUtil.exe
  PcapSplitter.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\PcapSplitter.exe
  IcmpFileTransfer-catcher.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\IcmpFileTransfer-catcher.exe
  IcmpFileTransfer-pitcher.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\IcmpFileTransfer-pitcher.exe
  IPFragUtil.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\IPFragUtil.exe
  HttpAnalyzer.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\HttpAnalyzer.exe
  DnsSpoofing.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\DnsSpoofing.exe
  IcmpV6Tests.cpp
  SSLAnalyzer.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\SSLAnalyzer.exe
  TLSFingerprinting.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\TLSFingerprinting.exe
  FilterTests.cpp
  TcpReassembly.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\TcpReassembly.exe
  IgmpTests.cpp
  benchmark.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\benchmark.exe
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/PcapPrinter/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/Arping/CMakeLists.txt
  IPFragmentationTests.cpp
  main.cpp
  main.cpp
  IPSecTests.cpp
  IPv4Tests.cpp
  PcapPrinter.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\PcapPrinter.exe
  IpMacTests.cpp
  Arping.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\Arping.exe
  IPv6Tests.cpp
D:\seladb\PcapPlusPlus\Tests\Pcap++Test\Tests\IpMacTests.cpp(300,52): warning C4129: '%': unrecognized character escape sequence [D:\seladb\PcapPlusPlus\build\Tests\Pcap++Test\Pcap+
+Test.vcxproj]
  KniTests.cpp
  LLCTests.cpp
  LiveDeviceTests.cpp
  NflogTests.cpp
  NtpTests.cpp
  LoggerTests.cpp
  PacketParsingTests.cpp
  Generating Code...
  PfRingTests.cpp
  RawSocketTests.cpp
  SystemUtilsTests.cpp
  Compiling...
  PacketTests.cpp
  TcpReassemblyTests.cpp
  XdpTests.cpp
  PacketUtilsTests.cpp
  Generating Code...
  PPPoETests.cpp
  RadiusTests.cpp
  S7CommTests.cpp
  SipSdpTests.cpp
  Pcap++Test.vcxproj -> D:\seladb\PcapPlusPlus\Tests\Pcap++Test\Bin\Pcap++Test.exe
  Sll2Tests.cpp
  SllNullLoopbackTests.cpp
  SmtpTests.cpp
  SomeIpSdTests.cpp
  SomeIpTests.cpp
  SSHTests.cpp
  SSLTests.cpp
  StpTests.cpp
  TcpTests.cpp
  TelnetTests.cpp
  TpktTests.cpp
  VlanMplsTests.cpp
  VrrpTest.cpp
  WakeOnLanTests.cpp
  Generating Code...
  Compiling...
  TestUtils.cpp
  Generating Code...
  Packet++Test.vcxproj -> D:\seladb\PcapPlusPlus\Tests\Packet++Test\Bin\Packet++Test.exe
  Building Custom Rule D:/seladb/PcapPlusPlus/CMakeLists.txt

D:\seladb\PcapPlusPlus>certutil -hashfile "build\Packet++\Debug\Packet++.lib" SHA1
SHA1 hash of build\Packet++\Debug\Packet++.lib:
06c03d73804c07d7b0fb1a887e3240ed10f20530
CertUtil: -hashfile command completed successfully.

D:\seladb\PcapPlusPlus>certutil -hashfile "build\Pcap++\Debug\Pcap++.lib" SHA1
SHA1 hash of build\Pcap++\Debug\Pcap++.lib:
eb25bf6aac27d731bc354660154f07f62890851b
CertUtil: -hashfile command completed successfully.

2nd run:

D:\seladb\PcapPlusPlus>rmdir build\ /s /q

D:\seladb\PcapPlusPlus>cmake -DPCAP_ROOT=D:\seladb\npcap-sdk -DPCAPPP_BUILD_REPRODUCIBLE=ON -S . -B build
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19045.
-- The CXX compiler identification is MSVC 19.25.28611.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is MSVC 19.25.28611.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test PCAP_LINKS_SOLO
-- Performing Test PCAP_LINKS_SOLO - Success
-- Looking for pcap_set_immediate_mode
-- Looking for pcap_set_immediate_mode - found
-- Looking for pcap_setdirection
-- Looking for pcap_setdirection - found
-- Looking for pcap_lib_version
-- Looking for pcap_lib_version - found
-- Found PCAP: D:/seladb/npcap-sdk/Lib/x64/wpcap.lib
-- Found Packet: D:/seladb/npcap-sdk/Lib/x64/Packet.lib
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Found Git: D:/Apps/Git/cmd/git.exe (found version "2.23.0.windows.1")
-- Building from commit:4423cd24 on branch:reproductible
-- Looking for backtrace
-- Looking for backtrace - not found
-- Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR)
-- Backtrace not found or not supported!
-- Building Example from PcapPlusPlus project
-- Configuring done
-- Generating done
-- Build files have been written to: D:/seladb/PcapPlusPlus/build

D:\seladb\PcapPlusPlus>cmake --build build -j
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule D:/seladb/PcapPlusPlus/3rdParty/LightPcapNg/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/3rdParty/hash-library/CMakeLists.txt
  md5.cpp
  light_advanced.c
  light_alloc.c
  light_compression.c
  light_internal.c
  light_io.c
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(91,56): warning C4133: '=': incompatible types - from 'light_file' to 'FILE *' [D:\seladb\PcapPlusPlus\build\3
rdParty\LightPcapNg\light_pcapng.vcxproj]
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(117,34): warning C4133: 'function': incompatible types - from 'FILE *' to 'light_file' [D:\seladb\PcapPlusPlus
\build\3rdParty\LightPcapNg\light_pcapng.vcxproj]
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(118,32): warning C4133: 'function': incompatible types - from 'FILE *' to 'light_file' [D:\seladb\PcapPlusPlus
\build\3rdParty\LightPcapNg\light_pcapng.vcxproj]
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(132,34): warning C4133: 'function': incompatible types - from 'FILE *' to 'light_file' [D:\seladb\PcapPlusPlus
\build\3rdParty\LightPcapNg\light_pcapng.vcxproj]
D:\seladb\PcapPlusPlus\3rdParty\LightPcapNg\LightPcapNg\src\light_io.c(155,31): warning C4133: 'function': incompatible types - from 'FILE *' to 'light_file' [D:\seladb\PcapPlusPlus
\build\3rdParty\LightPcapNg\light_pcapng.vcxproj]
  light_manipulate.c
  light_null_compression.c
  light_option.c
  light_pcapng_cont.c
  light_pcapng_ext.c
  light_pcapng.c
  light_platform.c
  light_zstd_compression.c
  Generating Code...
  hash-library.vcxproj -> D:\seladb\PcapPlusPlus\build\3rdParty\hash-library\hash-library.dir\Debug\hash-library.lib
  light_pcapng.vcxproj -> D:\seladb\PcapPlusPlus\build\3rdParty\LightPcapNg\light_pcapng.dir\Debug\light_pcapng.lib
  Building Custom Rule D:/seladb/PcapPlusPlus/Common++/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/3rdParty/MemPlumber/MemPlumber/CMakeLists.txt
  GeneralUtils.cpp
  memplumber.cpp
  IpAddress.cpp
  memplumber.vcxproj -> D:\seladb\PcapPlusPlus\build\3rdParty\MemPlumber\MemPlumber\Debug\memplumber.lib
  IpUtils.cpp
  Logger.cpp
  MacAddress.cpp
  OUILookup.cpp
  PcapPlusPlusVersion.cpp
  SystemUtils.cpp
  TablePrinter.cpp
  Generating Code...
  Common++.vcxproj -> D:\seladb\PcapPlusPlus\build\Common++\Debug\Common++.lib
  Building Custom Rule D:/seladb/PcapPlusPlus/Packet++/CMakeLists.txt
  ArpLayer.cpp
  BgpLayer.cpp
  CotpLayer.cpp
  DhcpLayer.cpp
  DhcpV6Layer.cpp
  DnsLayer.cpp
  DnsResource.cpp
  DnsResourceData.cpp
  EthDot3Layer.cpp
  EthLayer.cpp
  FtpLayer.cpp
  GreLayer.cpp
  GtpLayer.cpp
  HttpLayer.cpp
  IcmpLayer.cpp
  IcmpV6Layer.cpp
  IgmpLayer.cpp
  IPReassembly.cpp
  IPSecLayer.cpp
  IPv4Layer.cpp
  Generating Code...
  Compiling...
  IPv6Extensions.cpp
  IPv6Layer.cpp
  Layer.cpp
  LLCLayer.cpp
  MplsLayer.cpp
  NdpLayer.cpp
  NflogLayer.cpp
  NtpLayer.cpp
  NullLoopbackLayer.cpp
  Packet.cpp
  PacketTrailerLayer.cpp
  PacketUtils.cpp
  PayloadLayer.cpp
  PPPoELayer.cpp
  RadiusLayer.cpp
  RawPacket.cpp
  S7CommLayer.cpp
  SdpLayer.cpp
  SingleCommandTextProtocol.cpp
  SipLayer.cpp
  Generating Code...
  Compiling...
  Sll2Layer.cpp
  SllLayer.cpp
  SmtpLayer.cpp
  SomeIpLayer.cpp
  SomeIpSdLayer.cpp
  SSHLayer.cpp
  SSLCommon.cpp
  SSLHandshake.cpp
  SSLLayer.cpp
  StpLayer.cpp
  TcpLayer.cpp
  TcpReassembly.cpp
  TelnetLayer.cpp
  TextBasedProtocol.cpp
  TLVData.cpp
  TpktLayer.cpp
  UdpLayer.cpp
  VlanLayer.cpp
  VrrpLayer.cpp
  VxlanLayer.cpp
  Generating Code...
  Compiling...
  WakeOnLanLayer.cpp
  Generating Code...
  Packet++.vcxproj -> D:\seladb\PcapPlusPlus\build\Packet++\Debug\Packet++.lib
  Building Custom Rule D:/seladb/PcapPlusPlus/Pcap++/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Tests/Packet++Test/CMakeLists.txt
  NetworkUtils.cpp
  main.cpp
  PcapFileDevice.cpp
  BgpTests.cpp
  PcapDevice.cpp
  PcapFilter.cpp
  CotpTests.cpp
  PcapLiveDevice.cpp
  DhcpTests.cpp
  PcapLiveDeviceList.cpp
  DhcpV6Tests.cpp
  PcapRemoteDevice.cpp
  DnsTests.cpp
  PcapRemoteDeviceList.cpp
  RawSocketDevice.cpp
  WinPcapLiveDevice.cpp
  EthAndArpTests.cpp
  Generating Code...
  FtpTests.cpp
  Pcap++.vcxproj -> D:\seladb\PcapPlusPlus\build\Pcap++\Debug\Pcap++.lib
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/HttpAnalyzer/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/IPFragUtil/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/PcapSplitter/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/DnsSpoofing/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/DNSResolver/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/Arping/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/IPDefragUtil/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/IcmpFileTransfer/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/PcapPrinter/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/IcmpFileTransfer/CMakeLists.txt
  GreTests.cpp
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/TcpReassembly/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/SSLAnalyzer/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Tests/Pcap++Test/CMakeLists.txt
  main.cpp
  GtpTests.cpp
  main.cpp
  main.cpp
  Common.cpp
  Common.cpp
  main.cpp
  main.cpp
  main.cpp
  main.cpp
  main.cpp
  IcmpFileTransfer-pitcher.cpp
  IcmpFileTransfer-catcher.cpp
  main.cpp
  TestUtils.cpp
  main.cpp
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/ArpSpoofing/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/PcapPlusPlus-benchmark/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/PcapSearch/CMakeLists.txt
  Building Custom Rule D:/seladb/PcapPlusPlus/Examples/TLSFingerprinting/CMakeLists.txt
  HttpTests.cpp
  Generating Code...
  Generating Code...
  main.cpp
  main.cpp
D:\seladb\PcapPlusPlus\Tests\Pcap++Test\main.cpp(308,17): warning C4193: #pragma warning(pop): no matching '#pragma warning(push)' [D:\seladb\PcapPlusPlus\build\Tests\Pcap++Test\Pca
p++Test.vcxproj]
  IcmpTests.cpp
  DpdkTests.cpp
  main.cpp
  benchmark.cpp
  main.cpp
  FileTests.cpp
  DNSResolver.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\DNSResolver.exe
  PcapPrinter.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\PcapPrinter.exe
  HttpAnalyzer.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\HttpAnalyzer.exe
  Arping.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\Arping.exe
  IcmpV6Tests.cpp
  DnsSpoofing.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\DnsSpoofing.exe
  IPFragUtil.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\IPFragUtil.exe
  IPDefragUtil.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\IPDefragUtil.exe
  IcmpFileTransfer-catcher.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\IcmpFileTransfer-catcher.exe
  FilterTests.cpp
  IcmpFileTransfer-pitcher.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\IcmpFileTransfer-pitcher.exe
  PcapSplitter.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\PcapSplitter.exe
  ArpSpoofing.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\ArpSpoofing.exe
  SSLAnalyzer.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\SSLAnalyzer.exe
  IgmpTests.cpp
  benchmark.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\benchmark.exe
  TLSFingerprinting.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\TLSFingerprinting.exe
  PcapSearch.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\PcapSearch.exe
  IPFragmentationTests.cpp
  TcpReassembly.vcxproj -> D:\seladb\PcapPlusPlus\build\examples_bin\Debug\TcpReassembly.exe
  IPSecTests.cpp
  IPv4Tests.cpp
  IpMacTests.cpp
  IPv6Tests.cpp
D:\seladb\PcapPlusPlus\Tests\Pcap++Test\Tests\IpMacTests.cpp(300,52): warning C4129: '%': unrecognized character escape sequence [D:\seladb\PcapPlusPlus\build\Tests\Pcap++Test\Pcap+
+Test.vcxproj]
  LLCTests.cpp
  KniTests.cpp
  LiveDeviceTests.cpp
  NflogTests.cpp
  NtpTests.cpp
  LoggerTests.cpp
  PacketParsingTests.cpp
  Generating Code...
  PfRingTests.cpp
  RawSocketTests.cpp
  Compiling...
  PacketTests.cpp
  SystemUtilsTests.cpp
  TcpReassemblyTests.cpp
  PacketUtilsTests.cpp
  XdpTests.cpp
  Generating Code...
  PPPoETests.cpp
  RadiusTests.cpp
  S7CommTests.cpp
  SipSdpTests.cpp
  Pcap++Test.vcxproj -> D:\seladb\PcapPlusPlus\Tests\Pcap++Test\Bin\Pcap++Test.exe
  Sll2Tests.cpp
  SllNullLoopbackTests.cpp
  SmtpTests.cpp
  SomeIpSdTests.cpp
  SomeIpTests.cpp
  SSHTests.cpp
  SSLTests.cpp
  StpTests.cpp
  TcpTests.cpp
  TelnetTests.cpp
  TpktTests.cpp
  VlanMplsTests.cpp
  VrrpTest.cpp
  WakeOnLanTests.cpp
  Generating Code...
  Compiling...
  TestUtils.cpp
  Generating Code...
  Packet++Test.vcxproj -> D:\seladb\PcapPlusPlus\Tests\Packet++Test\Bin\Packet++Test.exe
  Building Custom Rule D:/seladb/PcapPlusPlus/CMakeLists.txt

D:\seladb\PcapPlusPlus>certutil -hashfile "build\Packet++\Debug\Packet++.lib" SHA1
SHA1 hash of build\Packet++\Debug\Packet++.lib:
9ded5b8efaad45f0411d5c3842e2b3452acf9daa
CertUtil: -hashfile command completed successfully.

D:\seladb\PcapPlusPlus>certutil -hashfile "build\Pcap++\Debug\Pcap++.lib" SHA1
SHA1 hash of build\Pcap++\Debug\Pcap++.lib:
79691e1657305120d0137665b8463fc97d3eabd0
CertUtil: -hashfile command completed successfully.

@clementperon
Copy link
Collaborator Author

clementperon commented Apr 23, 2024

@seladb thanks for the test, so there is still some work to do on Windows with MSVC.

As it's working on Apple, and Linux GCC + Clang can we merge it as it? It will help to confirm that the clang-format doesn't change the checksum.

I will see if I find some clue why it's not working on Windows

EDIT: I think you should build as release, and not as Debug, as it's expected that debug symbols could change between 2 builds

@clementperon clementperon changed the title cmake: add reproductible build option cmake: add reproducible build option Apr 23, 2024
@seladb
Copy link
Owner

seladb commented Apr 24, 2024

@clementperon I ran the same test with a release build and the hashes are still different:

First run:

D:\seladb\PcapPlusPlus>certutil -hashfile "build\Packet++\Release\Packet++.lib" SHA1
SHA1 hash of build\Packet++\Release\Packet++.lib:
199b8130a3e85e554d153d563fd425b461a030b1
CertUtil: -hashfile command completed successfully.

D:\seladb\PcapPlusPlus>certutil -hashfile "build\Pcap++\Release\Pcap++.lib" SHA1
SHA1 hash of build\Pcap++\Release\Pcap++.lib:
ba4aa36acb3b1252b2aa501c59065006f14eef20
CertUtil: -hashfile command completed successfully.

Second run:

D:\seladb\PcapPlusPlus>certutil -hashfile "build\Packet++\Release\Packet++.lib" SHA1
SHA1 hash of build\Packet++\Release\Packet++.lib:
34edd3a02890b81896ea29491a436ac2e4f30a38
CertUtil: -hashfile command completed successfully.

D:\seladb\PcapPlusPlus>certutil -hashfile "build\Pcap++\Release\Pcap++.lib" SHA1
SHA1 hash of build\Pcap++\Release\Pcap++.lib:
0de059c5602bef0b7a7f238b4e58a54307e44b4e
CertUtil: -hashfile command completed successfully.

@clementperon
Copy link
Collaborator Author

certutil

After reading some blog there is also an INCREMENTAL mode in MSVC that make it not exactly reproducible

@seladb
Copy link
Owner

seladb commented Apr 25, 2024

certutil

After reading some blog there is also an INCREMENTAL mode in MSVC that make it not exactly reproducible

Unfortunately it didn't solve the issue 😕

@clementperon
Copy link
Collaborator Author

clementperon commented May 25, 2024

@seladb I try to investigate but it seems to be not support for MSVC at least not for the static library.

It should be okay for executable

Source: https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html

@seladb
Copy link
Owner

seladb commented Jun 19, 2024

@clementperon do we still need this PR?

@clementperon
Copy link
Collaborator Author

clementperon commented Jun 19, 2024

@seladb as you wish but I work both on Apple and Linux. And I would be in favor that the package should be reproductible.

CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Owner

@seladb seladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see this comment: #1370 (comment)

Otherwise LGTM

@clementperon
Copy link
Collaborator Author

clementperon commented Jul 20, 2024

@tigercosmos @egecetin good for you ?

This could help for clang-format, if there is no sorting of the headers.

@tigercosmos
Copy link
Collaborator

@clementperon It looks good to me, but please address all CI issues.

@clementperon clementperon merged commit 11eb010 into seladb:dev Jul 29, 2024
38 checks passed
@clementperon clementperon deleted the reproductible branch July 29, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants