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

using packaged constant via packaged function produces undefined reference #59

Closed
hiyuh opened this issue Mar 19, 2014 · 1 comment
Closed

Comments

@hiyuh
Copy link
Contributor

hiyuh commented Mar 19, 2014

w/ proposed regression issueI,

package p is
    pure function f(
        i : boolean
    ) return integer;
end package p;

package body p is
    pure function f(
        i : boolean
    ) return integer is
    begin
        if (i = false) then
            return 0;
        else
            return 1;
        end if;
    end function f;
end package body p;

use work.p.all;
package q is
    constant d : integer := f(true) + 1;
end package q;

package body q is
end package body q;

use work.q.all;
entity issueI is
begin
    assert (d = 2);
end entity issueI;

architecture a of issueI is
begin
end architecture a;

then i got,

hiyuh@lynx ~/git-repos/nvc
$ ./tools/nvc-wrapper.sh -a test/regress/issueI.vhd
NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc -a test/regress/issueI.vhd

hiyuh@lynx ~/git-repos/nvc
$ ./tools/nvc-wrapper.sh --codegen p
NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc --codegen p
/usr/bin/opt -O2 -o /home/hiyuh/git-repos/nvc/work/_WORK.P-body.bc /home/hiyuh/git-repos/nvc/work/_WORK.P-body.bc
/usr/bin/llc -relocation-model=pic /home/hiyuh/git-repos/nvc/work/_WORK.P-body.bc
/usr/bin/gcc -shared -Wl,--export-all-symbols -Wl,--out-implib=/home/hiyuh/git-repos/nvc/work/_WORK.P-body.a -o /home/hiyuh/git-repos/nvc/work/_WORK.P-body.so /home/hiyuh/git-repos/nvc/work/_WORK.P-body.s -L./src -lnvcimp

hiyuh@lynx ~/git-repos/nvc
$ ./tools/nvc-wrapper.sh --codegen q
NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc --codegen q
/usr/bin/opt -O2 -o /home/hiyuh/git-repos/nvc/work/_WORK.Q-body.bc /home/hiyuh/git-repos/nvc/work/_WORK.Q-body.bc
/usr/bin/llc -relocation-model=pic /home/hiyuh/git-repos/nvc/work/_WORK.Q-body.bc
/usr/bin/gcc -shared -Wl,--export-all-symbols -Wl,--out-implib=/home/hiyuh/git-repos/nvc/work/_WORK.Q-body.a -o /home/hiyuh/git-repos/nvc/work/_WORK.Q-body.so /home/hiyuh/git-repos/nvc/work/_WORK.Q-body.s -L./src -lnvcimp /home/hiyuh/git-repos/nvc/work/_WORK.P-body.a

hiyuh@lynx ~/git-repos/nvc
$ ./tools/nvc-wrapper.sh -e issueI
NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc -e issueI
/usr/bin/opt -O2 -o /home/hiyuh/git-repos/nvc/work/_WORK.ISSUEI.final.bc /home/hiyuh/git-repos/nvc/work/_WORK.ISSUEI.elab.bc

hiyuh@lynx ~/git-repos/nvc
$ ./tools/nvc-wrapper.sh -r issueI
NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc -r issueI
LLVM ERROR: Could not resolve external global address: WORK.Q.D

hiyuh@lynx ~/git-repos/nvc
$ ./tools/nvc-wrapper.sh -e --native issueI
NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc -e --native issueI
/usr/bin/opt -O2 -o /home/hiyuh/git-repos/nvc/work/_WORK.ISSUEI.final.bc /home/hiyuh/git-repos/nvc/work/_WORK.ISSUEI.elab.bc
/usr/bin/llc -relocation-model=pic /home/hiyuh/git-repos/nvc/work/_WORK.ISSUEI.final.bc
/usr/bin/gcc -shared -Wl,--export-all-symbols -Wl,--out-implib=/home/hiyuh/git-repos/nvc/work/_WORK.ISSUEI.elab.a -o /home/hiyuh/git-repos/nvc/work/_WORK.ISSUEI.final.so /home/hiyuh/git-repos/nvc/work/_WORK.ISSUEI.final.s -L./src -lnvcimp /home/hiyuh/git-repos/nvc/work/_WORK.P-body.a /home/hiyuh/git-repos/nvc/work/_WORK.Q-body.a
/tmp/ccsCnK35.o:fake:(.text+0x5c): undefined reference to `WORK.Q.D'
collect2: error: ld returned 1 exit status
** Fatal: /usr/bin/gcc failed with status 256

NOTE: tools/nvc-wrapper.sh is my lazy wrapper script, echos some commands and eval them, you can found here. https://gist.github.com/hiyuh/9639531

IMHO, it looks similar scope problem as reported at issue #53.

@nickg
Copy link
Owner

nickg commented Mar 22, 2014

Fixed by the above commit

@nickg nickg closed this as completed Mar 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants