Keep in mind, that this is for a DEDICATED EVSE circuit, which NEC considers a continuous load.
Your load is a 40A continuous load, which requires a 50A branch circuit, appliance, and receptacle rating.
8 AWG wire is good for 40 amps for 60 degC systems, 50 amps for 75 degC systems, and 55 amps for 90 degC systems. To qualify for the 90 degC rating, *every* point in the system must be 90 degC rated -- and that can be tough. Typically, for ampacity purposes, you look at 60 degC for Romex (NM-B) and 75 degC for wire-in-conduit.
If you're using Romex (type NM cable), it's only good for 45 amps because by code it must be de-rated to the 60 degC rating (NEC 334). AWG 8 is good for 50 amps only if all connection points, breakers, conductors, termination boxes, etc., are all rated for 75 degC or higher. If you're running through an attic that has a high ambient temperature in the summer, you have to de-rate / correct for that per NEC tables 310.15(B)(2).
This is why many electricians will just forego #8 for 50A and install #6, which gives plenty of headroom for all de-rating needs.
So, Yes, go #6
You want 6-2 with a ground.
It has to be dedicated to meet code, and for gods sake, do not put an outlet in the system.
Hard wired!
NO GFI. (saw your other post)