Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

[ObjWriter/Linux] Integration into build process - #5091

Merged
jkotas merged 1 commit into
dotnet:masterfrom
BredPet:objwriter_build_integration
Dec 12, 2017
Merged

[ObjWriter/Linux] Integration into build process#5091
jkotas merged 1 commit into
dotnet:masterfrom
BredPet:objwriter_build_integration

Conversation

@BredPet

@BredPet BredPet commented Dec 11, 2017

Copy link
Copy Markdown
Contributor
- now it downloads llvm 5 release and uses it in the building objwriter
- add [objwriter] option into build.sh
- only Linux platform support
- cross building support(x86/x64 -> ARM32)

Later I'm going to add the following:

  • Documentation with the work's logic.
  • Additional trick related to the fact that the cross building for arm32 is x86, not the x64 host.
  • Integration ObjWriter build and general build to use the locally built ObjWriter.
  • Support for other platforms.

@dotnet/arm32-contrib please review

@BredPet
BredPet force-pushed the objwriter_build_integration branch 2 times, most recently from cdc960d to d3e3cda Compare December 11, 2017 09:33

# Make sure to remove debug flags from general build flags in Release case
if(OBJWRITER_BUILD_TYPE STREQUAL "Release")
list(REMOVE_ITEM CORERT_NATIVE_COMPILE_OPTIONS "-g")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Our convention has been to build with -g in Release, and then archive and strip the symbols on the binary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, just llvm picks up "-g" and binaries become very large. Of course, we can archive and strip it manually.

# Make sure to remove debug flags from general build flags in Release case
if(OBJWRITER_BUILD_TYPE STREQUAL "Release")
list(REMOVE_ITEM CORERT_NATIVE_COMPILE_OPTIONS "-g")
list(REMOVE_ITEM CORERT_NATIVE_COMPILE_OPTIONS "-O0")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should not be necessary. The compile options do not have -O0 for release build.

@BredPet BredPet Dec 11, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is in case the flags came from Debug version, but we are building Release)
Now, by default, Debug building is going to Release ObjWriter. I did this because Debug build is needed really rare. For Debug version, it's necessary to set OBJWRITER_BUILD_TYPE manually.

Comment thread src/Native/CMakeLists.txt Outdated
# Build ObjWriter on Linux only
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if($ENV{__ObjWriterBuild})
add_subdirectory(ObjWriter/llvmCap)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the Cap suffix a convention used for similar external projects? I do not see a problem with the name ... just wondering where it came from.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, maybe, any suggestions?)

@jkotas

jkotas commented Dec 11, 2017

Copy link
Copy Markdown
Member

cc @janvorli

@jkotas

jkotas commented Dec 11, 2017

Copy link
Copy Markdown
Member

LGTM otherwise. Thank you!

list(APPEND LLVM_CMAKE_EXTRA_ARGS "-DLLVM_DEFAULT_TARGET_TRIPLE=thumbv7-linux-gnueabi")
endif()

list(REMOVE_DUPLICATES CORERT_NATIVE_COMPILE_OPTIONS)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this needed?

@BredPet BredPet Dec 11, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just for ARM, it needs thumb triple, https://github.com/dotnet/corert/blob/master/src/Native/ObjWriter/objwriter.cpp#L307
As for the deletion of duplicates, in our project flags are set several times, just to simplify the transfer of arguments.
Moreover, there is a bug associated with the use of CMake toolchain file for our Native builds. For example, https://github.com/dotnet/corert/blob/master/cross/armel/toolchain.cmake#L40 here, CMAKE_EXE_LINKER_FLAGS for each rebuild will change and include itself twice, then three times and so on. Until the bash or CMake screams that the line of arguments is overflowing. This bug is repeated for other architectures too. I decided to fix it later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, thanks for the explanation. We should definitely fix it at the source of the issue, but I am ok doing that later. Could you please create an issue to track it (unless we already have it)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok)


if(NOT OBJWRITER_TARGET_ARCH)
if(CLR_CMAKE_TARGET_ARCH MATCHES "^(x64|x86)$")
if(NOT $ENV{__CrossBuild})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be cleaner to pass this as a CMake variable in gen-buildsys-clang.sh rather than using an env var. Basically, you'd just add the variable definition to the cmake_extra_defines in there based on the __CrossBuild value.

@BredPet BredPet Dec 11, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought about it. It seemed to me, it would complicate gen-buildsys-clang.sh logic. But if it's desirable to maintain a single style, I can do a little to change, so that there is no use of external variables from CMake.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is a matter of single style. It seems strange to have some parameters in env vars and some passed as defined variables using the cmake -D option. I personally prefer the -D option since it is more natural to cmake and also makes the behavior of the generated make files static. So basically, you generate make files and then when you run make, it always builds the same way no matter what the env settings are.
We use cmake in a slightly twisted way, the "native" way as I understand it is to run cmake only if the CMakeLists.txt are changed. Otherwise just run make.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll fix.

	- now it downloads llvm 5 release and uses it in the building ObjWriter
	- add [objwriter] option into build.sh
	- only Linux platform support
	- cross building support(x86/x64 -> ARM32)
	- LLVM is built in Release build type always,
	ObjWriter uses global project build type.

Signed-off-by: Petr Bred <bredpetr@gmail.com>
@BredPet
BredPet force-pushed the objwriter_build_integration branch from f8977b8 to 20b1c3e Compare December 12, 2017 18:40

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@jkotas
jkotas merged commit 9580df7 into dotnet:master Dec 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants