Opened 5 years ago

Last modified 14 months ago

#13081 new defect

Fix build with Visual Studio in Windows

Reported by: NewEraCracker Owned by:
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: tor-relay, msvc, lorax, intro, 029-proposed, windows, compiler, review-group-34
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

I have attached a patch to fix the missing objects during compilation.

The build process itself will have to be better documented in the future.

Child Tickets

TicketStatusOwnerSummaryComponent
#16030closedVisual Studio 2013 Test ProblemsCore Tor/Tor

Attachments (14)

fix-vs-build-win.txt (3.6 KB) - added by NewEraCracker 5 years ago.
building-tor-windows.txt (3.4 KB) - added by NewEraCracker 5 years ago.
fix-vs-build-win2.txt (8.2 KB) - added by NewEraCracker 5 years ago.
New patch for building TOR with VS. Includes test and tools build.
building-tor-windows2.txt (3.4 KB) - added by NewEraCracker 5 years ago.
New tutorial on how to build with VS.
fix-vs-build-win3.txt (9.3 KB) - added by NewEraCracker 5 years ago.
3rd version of patch to build Tor with VS. Fixes problems with OpenSSL.
tor-0.2.5.6-alpha-build-with-VS-4th-version-diff.txt (11.9 KB) - added by NewEraCracker 5 years ago.
New patch for building TOR with VS. Add build profiles and disable test build on Release profile.
building-tor-windows3.txt (4.1 KB) - added by NewEraCracker 5 years ago.
Tutorial as of Sept 11th
tor-0.2.5.6-alpha-build-with-VS-5th-version.diff (13.9 KB) - added by NewEraCracker 5 years ago.
Diff vs 0.2.5.6-alpha as of Sept 11th.
tor-maint-0.2.5-8eed82b.build-with-VS.diff.txt (14.0 KB) - added by NewEraCracker 5 years ago.
Patch to sync maint-0.2.5 8eed82b3d4bc8d15bd4ec7f229717f903dd6d6c7 with my tor-0.2.5.6-alpha-build-with-VS patch
tor-0.2.5.6-alpha-build-with-VS-5th-version.diff​ (13.9 KB) - added by NewEraCracker 5 years ago.
Diff vs 0.2.5.6-alpha as of Sept 11th.
fix-tor-0.2.5.10-win32-vs-build.diff (12.3 KB) - added by NewEraCracker 4 years ago.
Patch to make current version more compatible with VS2010
fix-tor-0.2.6.1-win32-vs-build-(work.in.progress).diff (23.0 KB) - added by NewEraCracker 4 years ago.
Patch to make current alpha version more compatible with VS2010. Still work in progress. Tests need to be fixed.
tor-0.2.5.12-msvs2010-build.diff (10.3 KB) - added by NewEraCracker 4 years ago.
tor-0.2.6.7-msvs2013-build.diff (17.0 KB) - added by NewEraCracker 4 years ago.

Download all attachments as: .zip

Change History (44)

Changed 5 years ago by NewEraCracker

Attachment: fix-vs-build-win.txt added

comment:1 Changed 5 years ago by NewEraCracker

Component: - Select a componentTor

comment:2 Changed 5 years ago by nickm

Keywords: tor-relay 025-backport added
Milestone: Tor: 0.2.6.x-final

Changed 5 years ago by NewEraCracker

Attachment: building-tor-windows.txt added

comment:3 Changed 5 years ago by NewEraCracker

I have attached a txt explaining how to build in Windows. Feel free to use this in documentation ;)

comment:4 Changed 5 years ago by NewEraCracker

I will also add tomorrow makefiles for tor-checkkey.c, tor-gencert.c and tor-resolve.c since I didn't found any for windows.

Also I will either disable test making in the main makefile or create a makefile for tests as it currently does not exist.

Changed 5 years ago by NewEraCracker

Attachment: fix-vs-build-win2.txt added

New patch for building TOR with VS. Includes test and tools build.

Changed 5 years ago by NewEraCracker

Attachment: building-tor-windows2.txt added

New tutorial on how to build with VS.

Changed 5 years ago by NewEraCracker

Attachment: fix-vs-build-win3.txt added

3rd version of patch to build Tor with VS. Fixes problems with OpenSSL.

comment:5 Changed 5 years ago by nickm

Keywords: msvc added; 025-backport removed
Status: newneeds_revision

I've applied the first one as obviously correct, and added the instructions as msvc-only, but the tests one isn't right. TOR_UNIT_TESTS should only be defined when doing a unit tests build: it interferes with hardening the application. If you can, maybe make a cleaned-up patch series that fixes one thing at a time, based on current maint-0.2.5 or master?

comment:6 Changed 5 years ago by NewEraCracker

The problem is that to build tests entire tor src will have to be built with TOR_UNIT_TESTS. I will have to figure a way to make some sort of makefile if flag to either build tor with TOR_UNIT_TESTS to enable tests or build tor without TOR_UNIT_TESTS and thus skip tests make file.

I will research into this.

Changed 5 years ago by NewEraCracker

New patch for building TOR with VS. Add build profiles and disable test build on Release profile.

comment:7 Changed 5 years ago by NewEraCracker

Also noticed a small typo in last patch

+!MESSAGE You are advised to clean your build tree before building a
+!MESSAGE diferent profile.

Should have been

+!MESSAGE You are advised to clean your build tree before building a
+!MESSAGE different profile.

comment:8 Changed 5 years ago by NewEraCracker

More one night of work.

Build process has been further improved.

  • Use /MD instead of /MT in building process. This will link everything to msvcr100.dll and is consistent with OpenSSL and Zlib builds in Windows. This also requires libevent to be built with /MD, a new tutorial will be uploaded shortly detailing new build process with this change.
  • More flags to compilation, common warnings enabled and deprecation warnings disabled, this behavior is consistent with Zlib builds in Windows.
  • Added missing io.h includes so VC knows better the function definitions, this was done in a coherent way as I have analyzed other source code files where io.h is included already.
  • Define HAVE_EXTERN_ENVIRON_DECLARED, MSVCR has that declared internally and we link to that with /MD.
  • Tests building improved, build the tests that were still missing.
  • Profile Debug renamed to Test, this is more consistent as we don't do any real Debug builds (yet) with MSVC.

I will be attaching new diff shortly.

Changed 5 years ago by NewEraCracker

Attachment: building-tor-windows3.txt added

Tutorial as of Sept 11th

Changed 5 years ago by NewEraCracker

Diff vs 0.2.5.6-alpha as of Sept 11th.

Changed 5 years ago by NewEraCracker

Patch to sync maint-0.2.5 8eed82b3d4bc8d15bd4ec7f229717f903dd6d6c7 with my tor-0.2.5.6-alpha-build-with-VS patch

Changed 5 years ago by NewEraCracker

Diff vs 0.2.5.6-alpha as of Sept 11th.

comment:9 Changed 5 years ago by NewEraCracker

By the way.

Some of my previous diffs had problems with orconfig.h inclusion in src/common/backtrace.c and moved that one to after the HAVE_* inclusions.

This has been fixed in the last two diffs uploaded at Sep 11, 2014 1:32:36 AM and Sep 11, 2014 1:36:23 AM.

The inclusions that are meant to be moved below are compat.h, util.h and torlog.h because at least one of them, didn't check which, causes problems with O_BINARY and O_TEXT defines in system includes.

Changed 4 years ago by NewEraCracker

Patch to make current version more compatible with VS2010

Changed 4 years ago by NewEraCracker

Patch to make current alpha version more compatible with VS2010. Still work in progress. Tests need to be fixed.

comment:10 Changed 4 years ago by yawning

Keywords: lorax added

We'd take a fix for VS2013, but it's unclear as to what the benefits are of supporting VS2010 at this point especially given the move to using more C99isms in the code.

Leaving this in for the 0.2.6.x milestone for now, but it probably will end up being deferred.

comment:11 Changed 4 years ago by nickm

Milestone: Tor: 0.2.6.x-finalTor: 0.2.???

comment:12 Changed 4 years ago by ikurua22

Why I can't use Code::Blocks or some other open-source compiler to build windows binary?
I don't trust Visual Studio because it was created by Microsoft.

VS is used by many companies - MS will use them as a puppet - to install hidden attack-code
or spyware inside its binary. Even the developer say "It's okay! My source code is open!",
he/she used VS for compile a binary, this is a huge security problem.

Please, don't use VS. Consider using MingGW, CodeBlocks, etc to create .exe files...

comment:13 in reply to:  12 Changed 4 years ago by yawning

Replying to ikurua22:

Why I can't use Code::Blocks or some other open-source compiler to build windows binary?
I don't trust Visual Studio because it was created by Microsoft.

There should be no reason why you currently can't use an open source (presumably gcc based) compiler to build a Windows tor binary.

VS is used by many companies - MS will use them as a puppet - to install hidden attack-code
or spyware inside its binary. Even the developer say "It's okay! My source code is open!",
he/she used VS for compile a binary, this is a huge security problem.

If you don't trust MS, the fact that Visual Studio may be subverted is the least of your problems, considering you're discussing making binaries that target an operating system they wrote. So if you paranoia is correct, then your ring 0 is subverted anyway and what compiler used doesn't really matter.

Please, don't use VS. Consider using MingGW, CodeBlocks, etc to create .exe files...

The tor browser builds are created via cross compiling using mingw. This is only a ticket to fix the build on modern VS versions so that people who wish to build in such enviornments can, because there's nothing wrong with keeping the code portable.

comment:14 Changed 4 years ago by NewEraCracker

Adding new patches for:

Tor 0.2.5.12 compatible with Visual Studio 2010. Supports Windows XP and higher.
Tor 0.2.6.7 compatible with Visual Studio 2013. Supports Windows Vista and higher.

Changed 4 years ago by NewEraCracker

Changed 4 years ago by NewEraCracker

comment:15 Changed 3 years ago by nickm

Keywords: intro added

comment:16 Changed 3 years ago by nickm

Points: medium
Severity: Normal

comment:17 Changed 3 years ago by NewEraCracker

I have started a Github repository that hosts this patches, latest tutorials I use to build Tor, and archived versions:
https://github.com/NewEraCracker/tor-win32-patches

Recently upgraded my (mega)patch to work on version 0.2.7.6
:)

comment:18 Changed 3 years ago by nickm

Keywords: 029-proposed added
Status: needs_revisionneeds_review

I think that applying the patches here would be a pretty fine thing, assuming they get reviewed again

comment:19 Changed 3 years ago by nickm

Keywords: review-group-3 added

This is the only 029-proposed ticket currently in needs_review; I'm optimistically calling it review-group-3.

comment:20 Changed 3 years ago by nickm

Reviewer: nickm

comment:21 Changed 3 years ago by nickm

Keywords: 029-nickm-says-no added

comment:22 Changed 2 years ago by teor

Milestone: Tor: 0.2.???Tor: 0.3.???

Milestone renamed

comment:23 Changed 2 years ago by nickm

Keywords: tor-03-unspecified-201612 added
Milestone: Tor: 0.3.???Tor: unspecified

Finally admitting that 0.3.??? was a euphemism for Tor: unspecified all along.

comment:24 Changed 2 years ago by nickm

Keywords: tor-03-unspecified-201612 removed

Remove an old triaging keyword.

comment:25 Changed 2 years ago by nickm

Keywords: review-group-3 removed

comment:26 Changed 2 years ago by nickm

Keywords: 029-nickm-says-no removed

comment:27 Changed 23 months ago by nickm

Keywords: windows compiler added

comment:28 Changed 14 months ago by teor

Milestone: Tor: unspecifiedTor: 0.3.4.x-final

Move all needs_review tickets without a release to 0.3.4

comment:29 Changed 14 months ago by nickm

Keywords: review-group-34 added

comment:30 Changed 14 months ago by dgoulet

Milestone: Tor: 0.3.4.x-finalTor: unspecified
Points: medium
Reviewer: nickm
Status: needs_reviewnew

Patch can't be merged because the given branch has 6 commits where first one is merging the entire tor codebase.

Treat this ticket has "Make Tor happy in Visual Studio".

Note: See TracTickets for help on using tickets.