Skip to content

Commit

Permalink
Enable link-time optimizations. (#2651)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Nov 29, 2024
1 parent b60ccd0 commit 7bbde29
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "top.h"

#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include <mbedtls/aes.h>

#include "resource.h"
Expand Down Expand Up @@ -45,16 +46,16 @@ class AesContext : public SimpleResource {
};

/*
AES-CBC context class.
AES-CBC context class.
In addition to the base AES context,
this cipher type also needs an initialization
this cipher type also needs an initialization
vector.
*/
class AesCbcContext : public AesContext {
public:
TAG(AesCbcContext);
AesCbcContext(SimpleResourceGroup* group, const Blob* key, const uint8* iv, bool encrypt);

uint8 iv_[AES_BLOCK_SIZE];
};

Expand Down
1 change: 1 addition & 0 deletions src/entropy_mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include <mbedtls/error.h>
#include <mbedtls/entropy.h>

Expand Down
1 change: 1 addition & 0 deletions src/primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include <mbedtls/aes.h>

#include "top.h"
Expand Down
1 change: 1 addition & 0 deletions src/primitive_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define CONFIG_TOIT_CRYPTO_EXTRA 1
#endif

#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include "mbedtls/gcm.h"
#include "mbedtls/chachapoly.h"

Expand Down
1 change: 1 addition & 0 deletions src/resources/tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
Expand Down
1 change: 1 addition & 0 deletions src/resources/x509.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include <mbedtls/x509_crt.h>

#include "../heap.h"
Expand Down
1 change: 1 addition & 0 deletions src/sha.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include <mbedtls/sha256.h>
#include <mbedtls/sha512.h>
#if MBEDTLS_VERSION_MAJOR >= 3
Expand Down
1 change: 1 addition & 0 deletions src/snapshot_bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "top.h"
#include "uuid.h"
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include <mbedtls/sha256.h>
#if MBEDTLS_VERSION_MAJOR >= 3
// Bring back the _ret names for sha functions.
Expand Down
2 changes: 2 additions & 0 deletions toolchains/arm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ set(CMAKE_CXX_FLAGS_DEBUG "-Og -ggdb3 -rdynamic -fdiagnostics-color $ENV{LOCAL_C
set(CMAKE_CXX_FLAGS_RELEASE "-Os $ENV{LOCAL_CXXFLAGS}" CACHE STRING "c++ Release flags")
set(CMAKE_CXX_FLAGS_ASAN "-O1 -fsanitize=address -fno-omit-frame-pointer -g" CACHE STRING "c++ Asan flags")
set(CMAKE_CXX_FLAGS_PROF "-Os -DPROF -pg" CACHE STRING "c++ Prof flags")

set(CMAKE_EXE_LINKER_FLAGS_RELEASE "$ENV{LOCAL_LDFLAGS}" CACHE STRING "Linker flags for release builds")
9 changes: 9 additions & 0 deletions toolchains/host.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ set(TOIT_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")

set(CMAKE_C_FLAGS_DEBUG "-O1 -g $ENV{LOCAL_CFLAGS}" CACHE STRING "c Debug flags")
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -ggdb3 -fdiagnostics-color $ENV{LOCAL_CXXFLAGS}" CACHE STRING "c++ Debug flags")
set(CMAKE_C_FLAGS_RELEASE "-Os $ENV{LOCAL_CFLAGS}" CACHE STRING "c Release flags")
set(CMAKE_CXX_FLAGS_RELEASE "-Os $ENV{LOCAL_CXXFLAGS}" CACHE STRING "c++ Release flags")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "$ENV{LOCAL_LDFLAGS}" CACHE STRING "Linker flags for release builds")

# If it's not windows add '-fo'
if (NOT WIN32)
set(CMAKE_C_FLAGS_RELEASE "-flto=auto ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "-flto=auto ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto ${CMAKE_EXE_LINKER_FLAGS}")
endif()

enable_testing()

0 comments on commit 7bbde29

Please sign in to comment.