fbc x64 compile to lib anomalies

General FreeBASIC programming questions.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

fbc x64 compile to lib anomalies

Post by srvaldez »

tested on Windows 10, FreeBASIC Compiler - Version 1.06.0 (06-03-2018), built for win64 (64bit)
the example used is the examples\dll\mydll, for convenience I post the code here.
mydll.bi

Code: Select all

declare function AddNumbers alias "AddNumbers"( byval a as integer, byval b as integer ) as integer
mydll.bas

Code: Select all

#include once "mydll.bi"
function AddNumbers( byval a as integer, byval b as integer) as integer export
	function = a + b
end function
test.bas

Code: Select all

#include "mydll.bi"
#inclib "mydll"

randomize( timer( ) )

dim as integer x = rnd( ) * 10
dim as integer y = rnd( ) * 10

print x; " +"; y; " ="; AddNumbers( x, y )
sleep
here are the results when compiling to static lib with various optimization options
fbc -asm intel -O 0 -lib mydll.bas
fbc -asm intel -O 2 test.bas
OK

fbc -asm intel -O 1 -lib mydll.bas
fbc -asm intel -O 2 test.bas
ld.exe: Cannot export H: symbol not found

fbc -asm intel -O 2 -lib mydll.bas
fbc -asm intel -O 2 test.bas
Warning: .drectve `H?A' unrecognized

fbc -asm intel -O 3 -lib mydll.bas
fbc -asm intel -O 2 test.bas
Warning: .drectve `H?A' unrecognized

fbc -asm intel -O s -lib mydll.bas
fbc -asm intel -O 2 test.bas
OK

fbc -asm intel -O fast -lib mydll.bas
fbc -asm intel -O 2 test.bas
OK
unfortunately no optimization doesn't always work, see viewtopic.php?p=244853#p244853
also when compiling using the gcc toolchain, I get a segfault when running the test, no matter what optimization level was used when compiling the lib.
Last edited by srvaldez on Aug 29, 2018 14:39, edited 2 times in total.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: fbc x64 compile to lib anomalies

Post by dodicat »

With version 1.05.0. 64 bit.
Win 10
Compiling to static ( -asm intel -Wc -O2 -lib)

I don't have version 1.06.0

I kept export in the code.
But I omitted alias in the declaration.
Seems OK.

Code: Select all

 5 + 2 = 7
 
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: fbc x64 compile to lib anomalies

Post by srvaldez »

thanks dodicat, I will have to check using version 1.05.
Last edited by srvaldez on Aug 28, 2018 12:47, edited 1 time in total.
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: fbc x64 compile to lib anomalies

Post by St_W »

The GCC version I'm using for my builds is quite old meanwhile (gcc 4.9.0 for x86, gcc 4.8.2 for x64). You could also try a testing build with gcc 8.1.0 from http://users.freebasic-portal.de/stw/bu ... om/gcc810/ . If that works it's probably some gcc bug.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: fbc x64 compile to lib anomalies

Post by srvaldez »

thank you St_W for the updated version, unfortunately the results for my test are the same.
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: fbc x64 compile to lib anomalies

Post by St_W »

srvaldez wrote:thank you St_W for the updated version, unfortunately the results for my test are the same.
hm, ok. Did you already try the official 1.05 release build as you mentioned above? If you get a different result (like it seems dodicat did) maybe you could also try older versions of my builds that should roughly match the official 1.05 release, like these:
32-bit: http://users.freebasic-portal.de/stw/bu ... -12-19.zip
64-bit: http://users.freebasic-portal.de/stw/bu ... -12-19.zip
If the 1.05 release result differs from my december 2015 builds then my builds are probably faulty; otherwise it looks like a regression on the current development version since the official 1.05 release. Thank you for your investigation of this issue.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: fbc x64 compile to lib anomalies

Post by srvaldez »

Hi St_W
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win64 (64bit), tested OK
also your version, FreeBASIC Compiler - Version 1.05.0 (12-19-2015), built for win64 (64bit) tested OK.

thank you St_W for your continued support :-)
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: fbc x64 compile to lib anomalies

Post by srvaldez »

I have msys2 installed on my VM with gcc version 8.2.0, if I copy the official FB 1.05 distribution for mingw toolchain the test segfaults
however with mingw x86_64-5.2.0-release-win32-sjlj-rt_v4-rev0 the test runs OK
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: fbc x64 compile to lib anomalies

Post by St_W »

srvaldez wrote:I have msys2 installed on my VM with gcc version 8.2.0, if I copy the official FB 1.05 distribution for mingw toolchain the test segfaults
however with mingw x86_64-5.2.0-release-win32-sjlj-rt_v4-rev0 the test runs OK
Mixing different toolchains (or toolchain versions) isn't a good idea in general and I'm not really surprised that this might cause segfaults. (with "mixing different toolchains" I mean the one used to compile fbc.exe itself and the fb runtime/gfxlib vs. the one used to compile programs with fbc.exe)
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: fbc x64 compile to lib anomalies

Post by srvaldez »

I am not sure I agree 100% with that assessment, however for what it's worth, I tested different versions of the win32-sjlj branch of mingw, and the latest version that compiles to lib and runs the test OK is MinGW-W64 GCC-6.4.0
I don't know what the problem is, I can only speculate but hopefully someone with a lot more knowledge than I have will look into this.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: fbc x64 compile to lib anomalies

Post by dodicat »

srvaldez
The team must be pretty desperate, as soon as I clicked your link it started downloading a .7z file.

Anyway I have
gcc version 5.2.0 (x86_64-win32-sjlj-rev0, Built by MinGW-W64 project)
Which must be the standard fb 1.05.0 gcc.exe, because I haven't changed anything since the day and hour I got it.

You asked me a while ago why I was griping about using gcc in FreeBASIC!
deltarho[1859]
Posts: 4292
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: fbc x64 compile to lib anomalies

Post by deltarho[1859] »

<deleted>
Derrils
Posts: 2
Joined: Sep 13, 2018 16:20

Re: fbc x64 compile to lib anomalies

Post by Derrils »

installed latest updates with the C++ tools installed.
I might be missing dependencies however when I open up the Developer Command Prompt and make the project it compiles fine for x86. I did try make all and it certainly tries but when it gets to x64 it seems to error out on:
iping_d.obj : error LNK2001: unresolved external symbol _iping_ProxyFileInfo
Would I be able to get any advice on this why it pops up when making for x64 and not x86 or am I being so stupid I'm not seeing what is wrong.
Derrils
Posts: 2
Joined: Sep 13, 2018 16:20

Re: fbc x64 compile to lib anomalies

Post by Derrils »

Trying to update the value for Editor but its just not working i am not sure i am doing or it is bug ww2

Code: Select all

import React, { Component } from "react";
import { Editor } from "primereact/editor";
import { Button } from "primereact/button";
import {InputTextarea} from 'primereact/inputtextarea';


export default class Note extends Component {
 
  state = {}


  componentDidUpdate = (prevProps) => {
    // Typical usage (don't forget to compare props):
    if (this.props.note.title !== prevProps.note.title) {
      this.setState({...this.props.note});
      setTimeout(() => {
        this.setState({body : 'your stuff'})
      }, 1000)
    }
  }
  
  onChange =(e) =>{
  
    this.setState({[e.target.name] : e.target.value})

  }

  getNote() {
    if (this.props.editMode === "read") {
      return (
        <div>
          <h1>{this.props.note.title}</h1>
          <hr />
          <div>{this.props.note.body}</div>
        </div>
      );
    } else
    
      return (
        
          <form>
            <input
              type="text"
              style={{
                width: "100%",
                fontWeight: "bold",
                height: "30px",
                paddingLeft: "5px"
              }}
              name="title"
              value={this.state.title}
              onChange={this.onChange}
            />
           <Editor style={{ height: "600px" }} 
           value={this.state.body}  
           key="body"
           name="body"
           onTextChange={(e)=> this.setState({body : e.htmlValue})} />      
            <br />
          {/* <InputTextarea value={this.state.body} style={{width:"100%" , height:"600px"}} 
          name="body" onChange={this.onChange} /> */}
          <Button label="Clear" icon="pi pi-times" onClick={(e)=> {e.preventDefault(); this.setState({body:''})}}/>
           
          </form>
        
      );
  }
  render() {
    return (

      <div className="noteContainer" style={{ background: "#f1f1f1" }}>
        <div id="presentation">
       
        {this.getNote()}
        </div>
        <div id="container-floating">
          <div
            id="floating-button"
            data-toggle="tooltip"
            data-placement="left"
            data-original-title="Create"
          >
            <p className="plus">+</p>
            <img
              className="edit"
              src="https://ssl.gstatic.com/bt/C3341AA7A1A076756462EE2E5CD71C11/1x/bt_compose2_1x.png"
            />
          </div>
        </div>
      </div>
    );
  }
}
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: fbc x64 compile to lib anomalies

Post by coderJeff »

srvaldez, I was not able to produce the errors you had in the opening post. But I have had other kinds of similar errors, usually due to incompatible libraries when linking, and the reason has always been using tools from different tool chains.

You can try passing '-v' option to fbc to get verbose output. fbc will print the target you are building and the paths of the tools being used. If fbc doesn't print absolute paths, then you will need to examine PATH setting for which tool is being run.

I have multiple tool chains installed on my system, and I must take care when setting up the build environment as to not mix tools and libraries. I am using standalone version only. And I typically 'set GCC=c:/path-to-gcc/gcc.exe' to explicitly direct fbc to use a specific version of gcc. For AS/AR binutils, I just copy in to fbc/bin/win64 directory. fbc 1.05.0 (standalone) should have all compatible tools in fbc/bin/win64.

I noticed that different tool chains configure gcc with different options ('gcc --verbose' to check configure options of gcc).

I think the error you mention in this thread is due the combination of tools, similar to what I was seeing with libdumb in the fbsound thread. However, the other other issue I mention in the fbsound thread, crashing gcc (inline asm + gen gcc), I am still researching. Currently I am suspecting "-mpreferred-stack-boundary=n" gcc option between older and newer versions of gcc, but I could be wrong.
Post Reply