Skip to content

Commit

Permalink
add clang support (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
wbenny committed Dec 21, 2018
1 parent 06372ef commit 0adda81
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 360 deletions.
19 changes: 7 additions & 12 deletions mini-tor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug_Clang|ARM64.ActiveCfg = Debug_Clang|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug_Clang|ARM64.Build.0 = Debug_Clang|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug_Clang|ARM64.ActiveCfg = Debug_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug_Clang|x64.ActiveCfg = Debug_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug_Clang|x64.Build.0 = Debug_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug_Clang|x86.ActiveCfg = Debug_Clang|Win32
Expand All @@ -57,26 +56,22 @@ Global
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug|x64.Build.0 = Debug|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug|x86.ActiveCfg = Debug|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Debug|x86.Build.0 = Debug|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|ARM64.ActiveCfg = Release_Clang|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|ARM64.Build.0 = Release_Clang|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|ARM64.ActiveCfg = Release_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|x64.ActiveCfg = Release_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|x64.Build.0 = Release_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|x86.ActiveCfg = Release_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|x86.Build.0 = Release_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small_Clang|ARM64.ActiveCfg = Release_Small_Clang|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small_Clang|ARM64.Build.0 = Release_Small_Clang|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|x86.ActiveCfg = Debug_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Clang|x86.Build.0 = Debug_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small_Clang|ARM64.ActiveCfg = Release_Small_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small_Clang|x64.ActiveCfg = Release_Small_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small_Clang|x64.Build.0 = Release_Small_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small_Clang|x86.ActiveCfg = Release_Small_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small_Clang|x86.Build.0 = Release_Small_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small|ARM64.ActiveCfg = Release_Small|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small|ARM64.Build.0 = Release_Small|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small|ARM64.ActiveCfg = Release_Small|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small|x64.ActiveCfg = Release_Small|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small|x64.Build.0 = Release_Small|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small|x86.ActiveCfg = Release_Small|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_Small|x86.Build.0 = Release_Small|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_STL_Clang|ARM64.ActiveCfg = Release_STL_Clang|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_STL_Clang|ARM64.Build.0 = Release_STL_Clang|ARM64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_STL_Clang|ARM64.ActiveCfg = Release_STL_Clang|Win32
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_STL_Clang|x64.ActiveCfg = Release_STL_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_STL_Clang|x64.Build.0 = Release_STL_Clang|x64
{6A9A9A93-E77E-44E3-B36E-2336A7EE9770}.Release_STL_Clang|x86.ActiveCfg = Release_STL_Clang|Win32
Expand Down
362 changes: 43 additions & 319 deletions mini-tor.vcxproj

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions mini/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ struct MINI_UNREFERENCED_PARAMETER_PACK_impl
}
};

//
// this macro marks unreachable code
//
#if defined(__clang__)
# define MINI_UNREACHABLE __builtin_unreachable()
# define MINI_COMPILER_CLANG
#elif defined(_MSC_VER)
# define MINI_COMPILER_MSVC
#else
# error "Unknown compiler!"
#endif

#if defined(MINI_COMPILER_CLANG)
# define MINI_UNREACHABLE __builtin_unreachable()
#elif defined(MINI_COMPILER_MSVC)
# define MINI_UNREACHABLE __assume(0)
#else
# define MINI_UNREACHABLE
Expand Down
1 change: 0 additions & 1 deletion mini/crt/crt0.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "crt0.h"
#if defined(MINI_CONFIG_NO_DEFAULT_LIBS)

#include <cstdlib>

#include <windows.h>
Expand Down
14 changes: 14 additions & 0 deletions mini/win32/pe/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ enum class image_directory_t
entry_com_descriptor = 14, // COM Runtime descriptor
};

#if defined(MINI_COMPILER_CLANG)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpragma-pack"
#endif
#include <pshpack2.h> // 16 bit headers are 2 byte packed

struct image_dos_header_t
Expand All @@ -142,6 +146,9 @@ struct image_dos_header_t
};

#include <poppack.h>
#if defined(MINI_COMPILER_CLANG)
# pragma GCC diagnostic pop
#endif

//
// File header format.
Expand Down Expand Up @@ -348,6 +355,10 @@ struct image_thunk_data_32_t
};
};

#if defined(MINI_COMPILER_CLANG)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpragma-pack"
#endif
#include <pshpack8.h> // Use align 8 for the 64-bit IAT.

struct image_thunk_data_64_t
Expand All @@ -362,6 +373,9 @@ struct image_thunk_data_64_t
};

#include <poppack.h> // Back to 4 byte packing
#if defined(MINI_COMPILER_CLANG)
# pragma GCC diagnostic pop
#endif

using image_thunk_data_t = std::conditional_t<
MINI_ARCH_BITS == 32,
Expand Down
1 change: 0 additions & 1 deletion mini/win32/pe/export_directory_enumerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "export_directory_enumerator.h"
#include "../pe.h"

Expand Down
1 change: 0 additions & 1 deletion mini/win32/pe/export_directory_enumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,4 @@ class pe_export_directory_enumerator
size_t _count;
};


}
12 changes: 11 additions & 1 deletion mini/win32/pe/import_directory_enumerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "import_directory_enumerator.h"
#include "../pe.h"

Expand Down Expand Up @@ -32,6 +31,17 @@ pe_import_directory_enumerator<TImageTraits>::pe_import_directory_enumerator(
}
}

template<
typename TImageTraits
>
pe_import_thunk_enumerator<TImageTraits>
pe_import_directory_enumerator<TImageTraits>::proxy::import_thunks(
void
) const
{
return pe_import_thunk_enumerator<TImageTraits>(_image_base, _import_descriptor_entry);
}

template <
typename TImageTraits
>
Expand Down
6 changes: 1 addition & 5 deletions mini/win32/pe/import_directory_enumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ class pe_import_directory_enumerator
pe_import_thunk_enumerator<TImageTraits>
import_thunks(
void
) const
{
return pe_import_thunk_enumerator<TImageTraits>(_image_base, _import_descriptor_entry);
}
) const;

private:
uint8_t* _image_base;
Expand Down Expand Up @@ -108,5 +105,4 @@ class pe_import_directory_enumerator
size_t _count;
};


}
1 change: 0 additions & 1 deletion mini/win32/pe/import_thunk_enumerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "import_thunk_enumerator.h"
#include "../pe.h"

Expand Down
1 change: 0 additions & 1 deletion mini/win32/pe/import_thunk_enumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class pe_import_thunk_enumerator
size_t _count;
};


}


15 changes: 13 additions & 2 deletions mini/win32/pe/relocation_directory_enumerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "relocation_directory_enumerator.h"
#include "../pe.h"

Expand All @@ -19,6 +18,18 @@ pe_relocation_directory_enumerator<TImageTraits>::pe_relocation_directory_enumer
_base_relocation_end = reinterpret_cast<typename TImageTraits::image_base_relocation_t*>(uintptr_t(_base_relocation.entry) + _base_relocation.size);
}


template<
typename TImageTraits
>
pe_relocation_fixup_enumerator<TImageTraits>
pe_relocation_directory_enumerator<TImageTraits>::proxy::fixups(
void
) const
{
return pe_relocation_fixup_enumerator<TImageTraits>(_image_base, _relocation);
}

template <
typename TImageTraits
>
Expand All @@ -41,7 +52,7 @@ pe_relocation_directory_enumerator<TImageTraits>::iterator::advance(
void
)
{
_relocation_current = reinterpret_cast<image_base_relocation_t*>(
_relocation_current = reinterpret_cast<typename TImageTraits::image_base_relocation_t*>(
uintptr_t(_relocation_current) + _relocation_current->size_of_block
);

Expand Down
6 changes: 1 addition & 5 deletions mini/win32/pe/relocation_directory_enumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ class pe_relocation_directory_enumerator
pe_relocation_fixup_enumerator<TImageTraits>
fixups(
void
) const
{
return pe_relocation_fixup_enumerator<TImageTraits>(_image_base, _relocation);
}
) const;

private:
uint8_t* _image_base;
Expand Down Expand Up @@ -112,5 +109,4 @@ class pe_relocation_directory_enumerator
typename TImageTraits::image_base_relocation_t* _base_relocation_end;
};


}
1 change: 0 additions & 1 deletion mini/win32/pe/relocation_fixup_enumerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "relocation_fixup_enumerator.h"
#include "../pe.h"

Expand Down
1 change: 0 additions & 1 deletion mini/win32/pe/relocation_fixup_enumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,4 @@ class pe_relocation_fixup_enumerator
size_t _count;
};


}
1 change: 0 additions & 1 deletion mini/win32/pe/resource_directory_enumerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "resource_directory_enumerator.h"
#include "../pe.h"

Expand Down
1 change: 0 additions & 1 deletion mini/win32/pe/resource_directory_enumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,4 @@ class pe_resource_directory_enumerator
pe_directory<typename TImageTraits::image_resource_directory_t> _top_resource_directory;
};


}
1 change: 0 additions & 1 deletion mini/win32/pe/section_enumerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "section_enumerator.h"
#include "../pe.h"

Expand Down
1 change: 0 additions & 1 deletion mini/win32/pe/tls_directory_enumerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include "tls_directory_enumerator.h"
#include "../pe.h"

Expand Down
1 change: 0 additions & 1 deletion mini/win32/pe/tls_directory_enumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,4 @@ class pe_tls_directory_enumerator
size_t _count;
};


}

0 comments on commit 0adda81

Please sign in to comment.