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

PAL's context2.S causes build to fail on FreeBSD #4094

Closed
josteink opened this issue Apr 2, 2015 · 10 comments · Fixed by dotnet/coreclr#624
Closed

PAL's context2.S causes build to fail on FreeBSD #4094

josteink opened this issue Apr 2, 2015 · 10 comments · Fixed by dotnet/coreclr#624
Labels
os-freebsd FreeBSD OS

Comments

@josteink
Copy link
Member

josteink commented Apr 2, 2015

This file did not cause issues back in February when the first attempts to port coreclr to FreeBSD was made. Since then only a few commits have been made.

These commits seems to have introduced platform-specific use of macros, which may or may not be the cause of the errors observed.

Error from the build can be seen below:

Commencing CoreCLR Repo build
Setting up directories for build
Checking pre-requisites...
Commencing build of native components for freebsd.x64.debug
Invoking cmake with arguments: "/home/josteink/build/coreclr" DEBUG
 -- Configuring done
 -- Generating done
 -- Build files have been written to: /home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug
Executing make install -j 3 [ 0%]
Built target debug-pal [ 0%]
Built target gcinfo [ 0%]
Building ASM object src/pal/src/CMakeFiles/CoreClrPal.dir/arch/i386/context2.S.o [ 1%]
Building CXX object src/utilcode/staticnohost/CMakeFiles/utilcodestaticnohost.dir/__/sstring_com.cpp.o 
/home/josteink/build/coreclr/src/pal/src/arch/i386/context2.S:93:10: error: unknown token in expression
 je 0f
    ^
/home/josteink/build/coreclr/src/pal/src/arch/i386/context2.S:109:11: error: unknown token in expression
 jmp 1f
     ^
/home/josteink/build/coreclr/src/pal/src/arch/i386/context2.S:114:10: error: unknown token in expression
 je 2f
    ^
/home/josteink/build/coreclr/src/pal/src/arch/i386/context2.S:135:10: error: unknown token in expression
 je 3f
    ^ 
/home/josteink/build/coreclr/src/pal/src/arch/i386/context2.S:139:10: error: unknown token in expression
 je 4f
    ^ 
/home/josteink/build/coreclr/src/pal/src/arch/i386/context2.S:158:42: error: unexpected token in argument list
 mov DWORD PTR [rdi + 6*8], (0x100000 | (1 | 2 | 8) | 4)
                                      ^
--- src/pal/src/CMakeFiles/CoreClrPal.dir/arch/i386/context2.S.o 
--- *** [src/pal/src/CMakeFiles/CoreClrPal.dir/arch/i386/context2.S.o] 
Error code 1
make[2]: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug
1 error
make[2]: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug --- src/pal/src/CMakeFiles/CoreClrPal.dir/all
--- *** [src/pal/src/CMakeFiles/CoreClrPal.dir/all]
Error code 2
make[1]: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug A failure has been detected in another branch of the parallel make 
make[2]: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug 
--- src/vm/dac/CMakeFiles/cee_dac.dir/all 
--- *** [src/vm/dac/CMakeFiles/cee_dac.dir/all]
Error code 2
make[1]: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug A failure has been detected in another branch of the parallel make
make[2]: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug --- src/utilcode/staticnohost/CMakeFiles/utilcodestaticnohost.dir/all 
--- *** [src/utilcode/staticnohost/CMakeFiles/utilcodestaticnohost.dir/all] 
Error code 2 
make[1]: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug 3 errors make[1]: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug 
*** [all] Error code 2 make: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug 
make: stopped in /usr/home/josteink/build/coreclr/binaries/intermediates/freebsd.x64.debug 
Failed to build coreclr components.
@janvorli
Copy link
Member

janvorli commented Apr 2, 2015

My change mostly just converted the file to the intel asm language syntax and added wrapper macros around the function name so that it generates proper name based on the target platform.
The wrappers don't seem to be related to the issues. It seems to complain about the numeric local labels syntax and also about the DWORD PTR (but it is happy with BYTE PTR).
I wonder if it is possible that the cmake uses some other assembler than the internal one in clang.
Could you please try go to /home/josteink/build/coreclr/src/pal/src and run "make -n"? You should then see the command line it used to compile the context2.S.

@josteink
Copy link
Member Author

josteink commented Apr 2, 2015

The logs gots their formatting ruined when pasted to Github. It's not the DWORD it fails at, it failed at the first pipe when trying to bitwise OR things together. You can see this if you inspect the column-number too.

You're still right about it complaining about number-formats though. I didn't think about that when submitting this!

Checking out "make -n" yielded some (to me) unsatisfactory results, so I'll get a clean environment and clean build and retry.

@josteink
Copy link
Member Author

josteink commented Apr 2, 2015

Are you sure "make -n" is the right command? After running a regular configure and build, this is the output I'm getting:

$ cd src/pal/src
$ make -n
make: no target to make.

make: stopped in /usr/home/josteink/build/cc2/src/pal/src
$ cd ..
$ make -n
make: no target to make.

make: stopped in /usr/home/josteink/build/cc2/src/pal
$ cd ..
$ make -n
make: no target to make.

make: stopped in /usr/home/josteink/build/cc2/src
$

@janvorli
Copy link
Member

janvorli commented Apr 2, 2015

I've tried something more specific on my Ubuntu. In the src/pal/src folder, I've issued this:

make -n -B arch/i386/context2.o

And the output was:

cd /home/janvorli/git/build && make -f src/pal/src/CMakeFiles/CoreClrPal.dir/build.make src/pal/src/CMakeFiles/CoreClrPal.dir/arch/i386/context2.S.o
/usr/bin/cmake -E cmake_progress_report /home/janvorli/git/build/CMakeFiles
/usr/bin/cmake -E cmake_echo_color --switch= --green "Building ASM object src/pal/src/CMakeFiles/CoreClrPal.dir/arch/i386/context2.S.o"
cd /home/janvorli/git/build/src/pal/src && /usr/bin/clang-3.5  -DBIT64=1 -DBUILDENV_CHECKED=1 -DCORECLR=1 -DDEBUG -DFEATURE_PAL=1 -DLP64COMPATIBLE=1 -DPIC=1 -DPLATFORM_UNIX=1 -DURTBLDENV_FRIENDLY=Checked -DWRITE_BARRIER_CHECK=1 -D_DBG -D_DEBUG -D_WIN64=1 -D__LINUX__=1 -g -I/home/janvorli/git/build/src/pal/src -I/home/janvorli/git/src/src/pal/src -I/home/janvorli/git/src/src/pal/inc -I/home/janvorli/git/src/src/pal/../inc -I/home/janvorli/git/src/src/pal/src/include    -gdwarf-3 -fexceptions -fstack-protector-all -fno-builtin -fPIC -o CMakeFiles/CoreClrPal.dir/arch/i386/context2.S.o -c /home/janvorli/git/src/src/pal/src/arch/i386/context2.S

@jkotas
Copy link
Member

jkotas commented Apr 2, 2015

For the last one, try whether either of these will help - both of these are changes towards the classic Intel syntax:

  • change 0x100000 constant at the top of the file to 100000h
  • change | (pipe) to OR

@kangaroo
Copy link
Contributor

kangaroo commented Apr 3, 2015

You can also use make VERBOSE=1, but it certainly does look like some other assembler is being used.

@josteink
Copy link
Member Author

josteink commented Apr 3, 2015

@janvorli It may be worth noting that I don't try to build PAL directly, but rather try to build it indirectly by building entire coreclr.

As far as I can tell src/pal/src doesn't have any makefile or CMakeFiles-folder. Thus the output from make -n -B ... doesn't seem consistent with the rest of the build as a whole:

$ make -n -B arch/i386/context2.o
cc -O2 -pipe    -c arch/i386/context2.S
$ cc --version
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.1
Thread model: posix
$ cc -O2 -pipe -c arch/i386/context2.S
arch/i386/context2.S:12:10: fatal error: 'unixasmmacros.inc' file not found
#include "unixasmmacros.inc"
         ^
1 error generated.
$

There's a few obvious things to notice here:

  • the make command doesn't look right at all.
  • clang is supposedly getting invoked, but not with any proper arguments. Version 3.4.1 is used, not 3,5 as found in /usr/local/llvm35/. Can this be a cause of error?
  • the error reported here doesn't show up in the real build.

Anyway, I would definitely agree with @kangaroo: It doesn't seem like the right tools are getting invoked, and I'd rather look into why that is happening, than you guys providing work-arounds at source-level.

Using your VERBOSE=1 trick gives me the following nugget from a real build:

Building ASM object src/pal/src/CMakeFiles/CoreClrPal.dir/arch/i386/context2.S.o
cd /home/josteink/build/cc2/bin/obj/FreeBSD.x64.Debug/src/pal/src && /usr/bin/clang  -DBIT64=1 -DBUILDENV_CHECKED=1 -DCORECLR=1 -DDEBUG -DFEATURE_PAL=1 -DLP64COMPATIBLE=1 -DPIC=1 -DPLATFORM_UNIX=1 -DURTBLDENV_FRIENDLY=Checked -DWRITE_BARRIER_CHECK=1 -D_DBG -D_DEBUG -D_WIN64=1 -g -I/home/josteink/build/cc2/bin/obj/FreeBSD.x64.Debug/src/pal/src -I/home/josteink/build/cc2/src/pal/src -I/home/josteink/build/cc2/src/pal/inc -I/home/josteink/build/cc2/src/pal/../inc -I/home/josteink/build/cc2/src/pal/src/include    -gdwarf-3 -fexceptions -fstack-protector-all -fno-builtin -fPIC -o CMakeFiles/CoreClrPal.dir/arch/i386/context2.S.o -c /home/josteink/build/cc2/src/pal/src/arch/i386/context2.S

It looks like clang is getting used, but the system-default 3.4.1 installation.

If I find a way to make this build correctly, what do you want me to do with that information? Create a PR for the readme with FreeBSD build-configuration instructions? Or something else?

@janvorli : I'll do some more checking with the build commands and verify that this builds properly, given the proper input.

@jkotas : I'll also check your suggestions, but if the wrong tools are getting invoked, I think it's better to fix the real problem instead of patching our way around it.

@josteink
Copy link
Member Author

josteink commented Apr 3, 2015

Using clang3.5 fixes this issue. The error is not detecting it on FreeBSD.

I will prepare a pull-request for this and that should be the end of this issue.

josteink referenced this issue in josteink/coreclr Apr 3, 2015
clang-3.5 is required to build correctly, but is not detected on FreeBSD
where it is aliased as clang35 and clang++35, not clang-3.5 and clang++-3.5.

This closes https://github.com/dotnet/coreclr/issues/615
@janvorli
Copy link
Member

janvorli commented Apr 3, 2015

LGTM, it is great to see this mystery resolved.

@kangaroo
Copy link
Contributor

kangaroo commented Apr 3, 2015

@janvorli I think you meant to LGTM on the PR (dotnet/coreclr#624) not the issue?

josteink referenced this issue in josteink/coreclr Apr 5, 2015
clang-3.5 is required to build correctly, but is not detected on FreeBSD
where it is aliased as clang35 and clang++35, not clang-3.5 and clang++-3.5.

This closes https://github.com/dotnet/coreclr/issues/615
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
os-freebsd FreeBSD OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants