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

Suggestion: Fortran support #870

Closed
interkosmos opened this issue Jun 28, 2020 · 15 comments
Closed

Suggestion: Fortran support #870

interkosmos opened this issue Jun 28, 2020 · 15 comments

Comments

@interkosmos
Copy link

Any chance that modern Fortran (2003/2008/2018) will be added to xmake? GNU Fortran, for instance, is part of GCC and close to the C compiler.

@waruqi
Copy link
Member

waruqi commented Jun 28, 2020

If more than 5 people want xmake to support fortran, I will consider supporting it.

@cnkjw
Copy link

cnkjw commented Jul 2, 2020

This is excellent advice, and I also hope that xmake will support FORTRAN projects.

@waruqi
Copy link
Member

waruqi commented Jul 4, 2020

I am supporting it, please see #882

If you can give me some examples of static libraries and dynamic library projects about fortran, maybe I will deal with them faster.

@waruqi waruqi added this to the v2.3.6 milestone Jul 4, 2020
@waruqi
Copy link
Member

waruqi commented Jul 5, 2020

I have supported gfortran compiler. Please update to dev version and try it. xmake update dev

Console project

$ xmake create -l fortran -t console test
$ cd test
$ xmake

xmake.lua

add_rules("mode.debug", "mode.release")

target("test")
    set_kind("binary")
    add_files("src/*.f90")

Static library project

$ xmake create -l fortran -t static test
$ cd test
$ xmake

Shared library project

$ xmake create -l fortran -t shared test
$ cd test
$ xmake

@interkosmos
Copy link
Author

Build xmake master on FreeBSD 12:

$ git clone --recurse-submodules https://github.com/xmake-io/xmake
$ cd xmake/
$ gmake
$ gmake install

Created a sample project test with Fortran program src/test.f90, and the following xmake file:

target("test")
    set_kind("binary")
    add_files("src/*.f90")

Then, the following error occurs:

$ xmake
error: ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:47: cannot get program for fc
stack traceback:
        [C]: in function 'error'
        @programdir/core/base/os.lua:792: in function 'raise'
        ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:47: in function 'co_start_named'
        @programdir/modules/private/async/runjobs.lua:180: in function <@programdir/modules/private/async/runjobs.lua:139>
        [C]: in function 'trycall'
        @programdir/core/base/scheduler.lua:423: in function 'co_group_begin'
        ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:85: in function 'co_group_begin'
        @programdir/modules/private/async/runjobs.lua:139: in function 'runjobs'
        @programdir/actions/build/build.lua:221: in function 'build'
        @programdir/actions/build/main.lua:115: in function <@programdir/actions/build/main.lua:110>
        [C]: in function 'trycall'
        @programdir/core/sandbox/modules/try.lua:121: in function 'try'
        @programdir/actions/build/main.lua:109: in function <@programdir/actions/build/main.lua:82>
        [C]: in function 'load'
        @programdir/core/base/task.lua:520: in function 'run'
        @programdir/core/main.lua:282: in function 'cotask'
        @programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315>

@waruqi
Copy link
Member

waruqi commented Jul 5, 2020

@interkosmos What's your fortran compiler? gfortran?

please run which gfortran and let me see it.

@interkosmos
Copy link
Author

interkosmos commented Jul 6, 2020

$ gfortran --version
GNU Fortran (FreeBSD Ports Collection) 9.3.
$ which gfortran
/usr/local/bin/gfortran

@waruqi
Copy link
Member

waruqi commented Jul 6, 2020

Please enter the non-project directory and run xmake l lib.detect.find_tool gfortran and let me see the results.

@interkosmos
Copy link
Author

$ xmake l lib.detect.find_tool gfortran
{ 
  program = "/usr/local/bin/gfortran",
  name = "gfortran" 
}

@waruqi
Copy link
Member

waruqi commented Jul 6, 2020

ok, can you run the following commands and get me output again. thanks.

cd test
xmake f -c -vD
xmake -vD

@interkosmos
Copy link
Author

$ xmake f -c -vD
checking for the architecture ... x86_64                                                                                        
checking for the gcc ... /usr/local/bin/gcc                                                                                     
configure                                                                                                           
{                                                                                   
    arch = x86_64                                                                                                               
    ccache = true                                                                                                               
    clean = true                                                                                                                
    plat = bsd                                                                                                                  
    kind = static                                                                                                               
    buildir = build                                                                                                             
    mode = release                                                                                                              
    host = bsd                                                                                                                  
}
$ xmake -vD
configure
{
    arch = x86_64
    ccache = true
    mode = release
    plat = bsd
    kind = static
    buildir = build
    clean = true
    host = bsd
}
[1;38;5;1;1merror: @programdir/core/main.lua:284: @programdir/actions/build/main.lua:123: ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:87: ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:47: @programdir/modules/private/async/runjobs.lua:207: ...amdir/core/sandbox/modules/import/core/tool/compiler.lua:39: cannot get program for fc
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:792]: in function 'raise'
    [...amdir/core/sandbox/modules/import/core/tool/compiler.lua:39]: in function 'load'
    [@programdir/modules/private/action/build/object.lua:39]: in function 'script'
    [@programdir/modules/private/action/build/object.lua:88]: in function '_build_object'
    [@programdir/modules/private/action/build/object.lua:113]: in function 'jobfunc'
    [@programdir/modules/private/async/runjobs.lua:185]:
    [C]: in function 'trycall'
    [@programdir/core/sandbox/modules/try.lua:121]: in function 'try'
    [@programdir/modules/private/async/runjobs.lua:182]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:317]:

stack traceback:
	[C]: in function 'error'
	@programdir/core/base/os.lua:792: in function 'raise'
	@programdir/modules/private/async/runjobs.lua:207: in function 'catch'
	@programdir/core/sandbox/modules/try.lua:127: in function 'try'
	@programdir/modules/private/async/runjobs.lua:182: in function 'cotask'
	@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315>
stack traceback:
	[C]: in function 'error'
	@programdir/core/base/os.lua:792: in function 'raise'
	...mdir/core/sandbox/modules/import/core/base/scheduler.lua:47: in function 'co_start_named'
	@programdir/modules/private/async/runjobs.lua:180: in function <@programdir/modules/private/async/runjobs.lua:139>
	[C]: in function 'trycall'
	@programdir/core/base/scheduler.lua:423: in function 'co_group_begin'
	...mdir/core/sandbox/modules/import/core/base/scheduler.lua:85: in function 'co_group_begin'
	@programdir/modules/private/async/runjobs.lua:139: in function 'runjobs'
	@programdir/actions/build/build.lua:221: in function 'build'
	@programdir/actions/build/main.lua:115: in function <@programdir/actions/build/main.lua:110>
	[C]: in function 'trycall'
	@programdir/core/sandbox/modules/try.lua:121: in function 'try'
	@programdir/actions/build/main.lua:109: in function <@programdir/actions/build/main.lua:82>
	[C]: in function 'load'
	@programdir/core/base/task.lua:520: in function 'run'
	@programdir/core/main.lua:282: in function 'cotask'
	@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315>
stack traceback:
	[C]: in function 'error'
	@programdir/core/base/os.lua:792: in function 'raise'
	@programdir/core/main.lua:284: in function 'cotask'
	@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315> 

@waruqi
Copy link
Member

waruqi commented Jul 6, 2020

I have fixed it. Please update to the lasted commit version and try it again.

@interkosmos
Copy link
Author

Can confirm, works.

@waruqi
Copy link
Member

waruqi commented Jul 6, 2020

Ok.

@waruqi waruqi closed this as completed Jul 6, 2020
@waruqi
Copy link
Member

waruqi commented Oct 7, 2020

now I have also supported for Intel Fortran Compiler on linux/macOS/windows.

#980

xmake f --toolchain=ifort -c
xmake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants